class MrYahooFinance::ProfitAndLoss
Attributes
data[R]
Public Class Methods
get(symbol, term)
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 8 def get(symbol, term) profit_and_loss = new(symbol, term) profit_and_loss.fetch profit_and_loss.data end
new(symbol, term)
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 17 def initialize(symbol, term) @symbol = symbol @term = term @data = Array.new(Config::TERMS_COUNT[@term]){ Hash.new } end
Public Instance Methods
fetch()
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 23 def fetch build_html parse_html if parseable?(@html) end
Private Instance Methods
build_html()
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 29 def build_html @html = Builder::Html.row_html Config::Url.send(@term.to_s, @symbol) end
build_periods(tr, base)
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 45 def build_periods(tr, base) case base when :period format_periods(tr) do |hash| @data.each_with_index{|data, i| data[base] = hash[i]} end else format_indicators(tr) do |hash| @data.each_with_index{|data, i| data[base] = hash[i]} end end end
format_indicators(tr) { |array| ... }
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 62 def format_indicators(tr) Builder::Format::Indicator.periods(tr, Config::TERMS_COUNT[@term]).tap{|array| yield array } end
format_periods(tr) { |array| ... }
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 58 def format_periods(tr) Builder::Format::Period.periods(tr, Config::TERMS_COUNT[@term]).tap{|array| yield array } end
parse_html()
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 33 def parse_html target_table_tr do |tr| Config::Indicator::ALL.each do |key, value| build_periods(tr, key) if valid?(tr, value) end end end
target_table_tr() { |tr| ... }
click to toggle source
# File lib/mr_yahoo_finance/profit_and_loss.rb, line 41 def target_table_tr Builder::Html.target_table_tr(@html).each{|tr| yield tr } end