Class: Demos::StockDecider::App
Instance Attribute Summary
#node, #provides, #publisher
Instance Method Summary
collapse
#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, inject, inject!, #method_missing, mount, #on_resize, provide, provides, #render, style, styles_get, template, template_from_file, template_get, #update, use, uses
Constructor Details
#initialize(**args) ⇒ App
Returns a new instance of App.
104
105
106
107
|
# File 'ui/examples/stock.rb', line 104
def initialize(**args)
@options = {}
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hokusai::Block
Instance Method Details
#add_ticker(sym) ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'ui/examples/stock.rb', line 95
def add_ticker(sym)
ticker_opts = Option.from_ticker(sym)
w3 = ticker_opts.select { |a| a.attractive?(3) }.sort_by { |a| a.percent(3) }.last
w4 = ticker_opts.select { |a| a.attractive?(4) }.sort_by { |a| a.percent(4) }.last
w5 = ticker_opts.select { |a| a.attractive?(5) }.sort_by { |a| a.percent(5) }.last
@options[sym] = [w3&.percent(3), w4&.percent(4), w5&.percent(5)]
puts @options[sym]
end
|
#attractive_options ⇒ Object
80
81
82
|
# File 'ui/examples/stock.rb', line 80
def attractive_options
@options.to_a
end
|
#key(index) ⇒ Object
84
85
86
|
# File 'ui/examples/stock.rb', line 84
def key(index)
"Key_#{index}"
end
|
#on_mounted ⇒ Object
88
89
90
91
92
93
|
# File 'ui/examples/stock.rb', line 88
def on_mounted
puts ["mounted"]
add_ticker("TSLA")
add_ticker("OXY")
add_ticker("DG")
end
|