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.
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/yahoofinance.rb', line 254
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
282
283
284
|
# File 'lib/yahoofinance.rb', line 282
def get_info()
"#{symbol} : #{name}"
end
|
#load_quote(symbol) ⇒ Object
271
272
273
274
|
# File 'lib/yahoofinance.rb', line 271
def load_quote( symbol )
csv = YahooFinance.get( symbol, @formathash.keys.join )
parse( CSV.parse_line( csv ) )
end
|
#to_s ⇒ Object
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/yahoofinance.rb', line 286
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
276
277
278
279
280
|
# File 'lib/yahoofinance.rb', line 276
def valid?()
return self.name != self.symbol if self.name
false
end
|