Class: RubyToBlock::Block::HardwareRgbLedSetColor
- Inherits:
-
CharacterMethodCall
- Object
- Base
- CharacterMethodCall
- RubyToBlock::Block::HardwareRgbLedSetColor
- Defined in:
- app/models/concerns/ruby_to_block/block/hardware_rgb_led_set_color.rb
Constant Summary
Constants included from CharacterOperation
CharacterOperation::CHAR_NAME_RE, CharacterOperation::CHAR_RE
Instance Attribute Summary
Attributes included from CharacterOperation
Attributes inherited from Base
#fields, #parent, #prev_sibling, #sibling, #statements, #values
Class Method Summary collapse
-
.process_match_data(md, context) ⇒ Object
rubocop:enable LineLength.
Methods inherited from CharacterMethodCall
add_character_method_call_block
Methods inherited from Base
#[], #add_statement, #add_value, blocknize, indent?, #indent_level, inherited, #initialize, inline?, #inline?, #null?, priority, process_else, process_end, process_value_string, regexp, statement?, #to_xml, type, #type, value?
Constructor Details
This class inherits a constructor from RubyToBlock::Block::Base
Class Method Details
.process_match_data(md, context) ⇒ Object
rubocop:enable LineLength
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/concerns/ruby_to_block/block/hardware_rgb_led_set_color.rb', line 10 def self.process_match_data(md, context) md2 = regexp.match(md[type]) color = [md2[4], md2[5], md2[6]].map(&:to_i) return false if color.any? { |c| c < 0 || c > 255 } color_code = '#' + color.map { |c| sprintf('%02x', c) }.join block = new(fields: { AC: md2[2], PIN: md2[3], COLOUR: color_code }) add_character_method_call_block(context, md2[1], block) true end |