Class: MyTradeWizard::Action
- Inherits:
-
Object
- Object
- MyTradeWizard::Action
- Defined in:
- lib/mytradewizard/action.rb
Instance Method Summary collapse
-
#initialize(signal) ⇒ Action
constructor
A new instance of Action.
- #nil? ⇒ Boolean
- #reverse ⇒ Object
- #reverse! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(signal) ⇒ Action
Returns a new instance of Action.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/mytradewizard/action.rb', line 4 def initialize(signal) case signal when "BUY" @signal = 1 when "SELL" @signal = -1 else @signal = signal end end |
Instance Method Details
#nil? ⇒ Boolean
34 35 36 |
# File 'lib/mytradewizard/action.rb', line 34 def nil? @signal == 0 end |
#reverse ⇒ Object
30 31 32 |
# File 'lib/mytradewizard/action.rb', line 30 def reverse return MyTradeWizard::Action.new(-@signal) end |
#reverse! ⇒ Object
25 26 27 28 |
# File 'lib/mytradewizard/action.rb', line 25 def reverse! @signal = -@signal return self end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/mytradewizard/action.rb', line 15 def to_s if @signal > 0 return "BUY" elsif @signal < 0 return "SELL" else return "None" end end |