Class: FundamentusParser

Inherits:
Object
  • Object
show all
Defined in:
lib/fundamentus_data/fundamentus_parser.rb

Constant Summary collapse

LABEL_MAP =
{
  :share_count => 'Nro. Ações',
  :market_cap => 'Valor de mercado',
  :last_processed => 'Últ balanço processado',
  :pl => 'P/L',
  :pvp => 'P/VP',
  :pebit => 'P/EBIT',
  :lpa => 'LPA',
  :vpa => 'VPA',
  :net_margin => 'Marg. Líquida',
  :net_debt => 'Dív. Líquida',
  :net_assets => 'Patrim. Líq',
  :yearly_net_income => 'Receita Líquida',
  :yearly_net_profit => 'Lucro Líquido',
  :quarterly_net_income => ['Receita Líquida', 2],
  :quarterly_net_profit => ['Lucro Líquido', 2]
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FundamentusParser

Returns a new instance of FundamentusParser.



23
24
25
26
27
# File 'lib/fundamentus_data/fundamentus_parser.rb', line 23

def initialize(options = {})
  if options.has_key?(:verbose)
    @verbose = options[:verbose]
  end
end

Instance Method Details

#parse(content) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fundamentus_data/fundamentus_parser.rb', line 29

def parse(content)
  @doc = Nokogiri::HTML.parse(content)
  parsed = {}
  LABEL_MAP.each do |key, label|
    if label.is_a?(Array)
      parsed[key] = read_value_with_label(label[0], label[1])
    else
      parsed[key] = read_value_with_label(label)
    end
  end
  parsed
end