Class: Taopaipai::PinState

Inherits:
Object
  • Object
show all
Defined in:
lib/taopaipai/pin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  @number = options[:number]
  self.direction = options[:direction]
  self.value = options[:value]
end

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



58
59
60
# File 'lib/taopaipai/pin.rb', line 58

def direction
  @direction
end

#numberObject (readonly)

Returns the value of attribute number.



58
59
60
# File 'lib/taopaipai/pin.rb', line 58

def number
  @number
end

#valueObject

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

Returns:

  • (Boolean)


89
90
91
# File 'lib/taopaipai/pin.rb', line 89

def in?
  direction == :in
end

#out?Boolean

Returns:

  • (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