Class: Taopaipai::PinState
- Inherits:
-
Object
- Object
- Taopaipai::PinState
- Defined in:
- lib/taopaipai/pin.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #changing(attribute, update) ⇒ Object
- #export! ⇒ Object
- #in? ⇒ Boolean
-
#initialize(options = {}) ⇒ PinState
constructor
A new instance of PinState.
- #out? ⇒ Boolean
- #unexport! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PinState
Returns a new instance of PinState.
60 61 62 63 64 |
# File 'lib/taopaipai/pin.rb', line 60 def initialize(={}) @number = [:number] self.direction = [:direction] self.value = [:value] end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
58 59 60 |
# File 'lib/taopaipai/pin.rb', line 58 def direction @direction end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
58 59 60 |
# File 'lib/taopaipai/pin.rb', line 58 def number @number end |
#value ⇒ Object
Returns the value of attribute value.
58 59 60 |
# File 'lib/taopaipai/pin.rb', line 58 def value @value end |
Instance Method Details
#changing(attribute, update) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/taopaipai/pin.rb', line 66 def changing(attribute, update) if send(attribute) != update send "#{attribute}=", update yield if block_given? end end |
#export! ⇒ Object
97 98 99 100 |
# File 'lib/taopaipai/pin.rb', line 97 def export! return false if @exported @exported = true end |
#in? ⇒ Boolean
89 90 91 |
# File 'lib/taopaipai/pin.rb', line 89 def in? direction == :in end |
#out? ⇒ Boolean
93 94 95 |
# File 'lib/taopaipai/pin.rb', line 93 def out? direction == :out end |
#unexport! ⇒ Object
102 103 104 105 106 |
# File 'lib/taopaipai/pin.rb', line 102 def unexport! return false unless @exported @exported = false true end |