class Taopaipai::PinState
Attributes
direction[R]
number[R]
value[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/taopaipai/pin.rb, line 60 def initialize(options={}) @number = options[:number] self.direction = options[:direction] self.value = options[:value] end
Public Instance Methods
changing(attribute, update) { || ... }
click to toggle source
# File lib/taopaipai/pin.rb, line 66 def changing(attribute, update) if send(attribute) != update send "#{attribute}=", update yield if block_given? end end
direction=(direction)
click to toggle source
# File lib/taopaipai/pin.rb, line 73 def direction=(direction) direction = direction.to_s.to_sym unless [:in, :out].include?(direction) raise "Invalid direction \"#{direction}\", should be one of \"in\", \"out\"" end @direction = direction end
export!()
click to toggle source
# File lib/taopaipai/pin.rb, line 97 def export! return false if @exported @exported = true end
in?()
click to toggle source
# File lib/taopaipai/pin.rb, line 89 def in? direction == :in end
out?()
click to toggle source
# File lib/taopaipai/pin.rb, line 93 def out? direction == :out end
unexport!()
click to toggle source
# File lib/taopaipai/pin.rb, line 102 def unexport! return false unless @exported @exported = false true end
value=(v)
click to toggle source
# File lib/taopaipai/pin.rb, line 81 def value=(v) v = v.to_i unless (0..1).include?(v) raise "Invalid value \"#{v}\", should be one of 0, 1" end @value = v end