Class: YahooFinance::BaseQuote
- Inherits:
-
Object
- Object
- YahooFinance::BaseQuote
show all
- Defined in:
- lib/yahoofinance.rb
Instance Method Summary
collapse
Constructor Details
#initialize(hash, valarray = nil) ⇒ BaseQuote
Returns a new instance of BaseQuote.
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# File 'lib/yahoofinance.rb', line 240
def initialize( hash, valarray=nil )
@formathash = hash
@formathash.each_key { |elem|
instance_eval( "def #{@formathash[elem][0]}() " +
"@#{@formathash[elem][0]} " +
"end" )
instance_eval( "def #{@formathash[elem][0]}=(val) " +
"@#{@formathash[elem][0]}=#{@formathash[elem][1]} " +
"end" )
}
parse( valarray ) if valarray
end
|
Instance Method Details
#get_info ⇒ Object
268
269
270
|
# File 'lib/yahoofinance.rb', line 268
def get_info()
"#{symbol} : #{name}"
end
|
#load_quote(symbol) ⇒ Object
257
258
259
260
|
# File 'lib/yahoofinance.rb', line 257
def load_quote( symbol )
csv = YahooFinance.get( symbol, @formathash.keys.join )
parse( CSV.parse_line( csv ) )
end
|
#to_s ⇒ Object
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/yahoofinance.rb', line 272
def to_s()
ret = String.new
ret << self.class.name << "\n"
@formathash.each_value { |val|
ret << "#{val[0]} = "
ret << send( val[0] ).to_s unless send( val[0] ) == nil
ret << "\n"
}
return ret
end
|
#valid? ⇒ Boolean
262
263
264
265
266
|
# File 'lib/yahoofinance.rb', line 262
def valid?()
return self.name != self.symbol if self.name
false
end
|