Class: Edgar::Edgar

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

Constant Summary collapse

@@config =

Configuration defaults

{
    :lookup_offset => -1,
    :round_to => 2
}
@@valid_config_keys =
@@config.keys

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Edgar

Returns a new instance of Edgar.



27
28
29
30
31
32
33
# File 'lib/edgar.rb', line 27

def initialize(symbol)
  @symbol = symbol

  # Perform the actual lookup of historical data and parse it into arrays that
  # are cached in memory
  @data = CSV.parse(lookup)
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



9
10
11
# File 'lib/edgar.rb', line 9

def symbol
  @symbol
end

Class Method Details

.configObject



23
24
25
# File 'lib/edgar.rb', line 23

def self.config
  @@config
end

.configure(opts = {}) ⇒ Object



19
20
21
# File 'lib/edgar.rb', line 19

def self.configure(opts = {})
  opts.each {|k,v| @@config[k.to_sym] = v if @@valid_config_keys.include? k.to_sym}
end

Instance Method Details

#closing_price(date = DateTime.now, running = 1) ⇒ Object



35
36
37
# File 'lib/edgar.rb', line 35

def closing_price(date = DateTime.now, running = 1)
  lookup_by_column(running, date, 4)
end

#high_price(date = DateTime.now, running = 1) ⇒ Object



43
44
45
# File 'lib/edgar.rb', line 43

def high_price(date = DateTime.now, running = 1)
  lookup_by_column(running, date, 2)
end

#low_price(date = DateTime.now, running = 1) ⇒ Object



47
48
49
# File 'lib/edgar.rb', line 47

def low_price(date = DateTime.now, running = 1)
  lookup_by_column(running, date, 3)
end

#opening_price(date = DateTime.now, running = 1) ⇒ Object



39
40
41
# File 'lib/edgar.rb', line 39

def opening_price(date = DateTime.now, running = 1)
  lookup_by_column(running, date, 1)
end

#volume(date = DateTime.now, running = 1) ⇒ Object



51
52
53
# File 'lib/edgar.rb', line 51

def volume(date = DateTime.now, running = 1)
  lookup_by_column(running, date, 5)
end