Was ist die korrekte Möglichkeit, die Ausgabe der puts
Aussagen unten zu sehen? Ich entschuldige mich für eine so einfache Frage .... Ich bin ein wenig rostig auf Rubin. verwenden github repoRuby-Objekt to_s gibt unerwartete Ausgabe
require 'active_support'
require 'active_support/core_ext'
require 'indicators'
my_data = Indicators::Data.new(Securities::Stock.new(:symbol => 'AAPL', :start_date => '2012-08-25', :end_date => '2012-08-30').output)
puts my_data.to_s #expected to see Open,High,Low,Close for AAPL
temp=my_data.calc(:type => :sma, :params => 3)
puts temp.to_s #expected to see an RSI value for each data point from the data above
Wie würde ich auf die Attribute zugreifen? zum Beispiel wenn 'temp.inspect '' #' –
Rilcon42
'puts temp @ output 'funktioniert nicht – Rilcon42
' puts temp @ output' ist keine gültige Ruby-Syntax. Wenn 'output' eine Methode für' temp' ist, verwenden Sie 'temp.output'. Wenn 'output' eine Instanzvariable ist, versuchen Sie' temp.instance_variable_get ("@ output") ' –