Class: Knipper::Pattern::PatternLine
- Inherits:
-
Object
- Object
- Knipper::Pattern::PatternLine
- Defined in:
- lib/knipper/pattern/pattern_line.rb
Constant Summary collapse
- PATTERN =
/\A(\d+),(\d+),(\d+),(\d+)\z/
Instance Attribute Summary collapse
-
#blue ⇒ Object
Returns the value of attribute blue.
-
#green ⇒ Object
Returns the value of attribute green.
-
#millis ⇒ Object
Returns the value of attribute millis.
-
#red ⇒ Object
Returns the value of attribute red.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ PatternLine
constructor
A new instance of PatternLine.
Constructor Details
#initialize(attributes = {}) ⇒ PatternLine
Returns a new instance of PatternLine.
21 22 23 24 25 |
# File 'lib/knipper/pattern/pattern_line.rb', line 21 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#blue ⇒ Object
Returns the value of attribute blue.
4 5 6 |
# File 'lib/knipper/pattern/pattern_line.rb', line 4 def blue @blue end |
#green ⇒ Object
Returns the value of attribute green.
4 5 6 |
# File 'lib/knipper/pattern/pattern_line.rb', line 4 def green @green end |
#millis ⇒ Object
Returns the value of attribute millis.
4 5 6 |
# File 'lib/knipper/pattern/pattern_line.rb', line 4 def millis @millis end |
#red ⇒ Object
Returns the value of attribute red.
4 5 6 |
# File 'lib/knipper/pattern/pattern_line.rb', line 4 def red @red end |
Class Method Details
.parse(s) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/knipper/pattern/pattern_line.rb', line 8 def self.parse(s) parts = PATTERN.match(s) raise "Unrecognized pattern -- #{s}" unless parts pattern_line = PatternLine.new pattern_line.millis = parts[1].to_i pattern_line.red = parts[2].to_i pattern_line.green = parts[3].to_i pattern_line.blue = parts[4].to_i pattern_line end |