Sha256: 11e675a8bec5df972b4139ae92d2dbd236d994efcf400b62ebfae9e8e548b0ab
Contents?: true
Size: 784 Bytes
Versions: 34
Compression:
Stored size: 784 Bytes
Contents
# -*- coding: utf-8 -*- module RubyToBlock module Block class HardwareRgbLedSetColor < CharacterMethodCall # rubocop:disable LineLength blocknize '^\s*' + CHAR_RE + 'rgb_led_(anode|cathode)\("(D[39])"\).color\s*=\s*\[(\d+),\s*(\d+),\s*(\d+)\]\s*$', statement: true # rubocop:enable LineLength 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 end end end
Version data entries
34 entries across 34 versions & 1 rubygems