Sha256: 644ec0b0f6fdb9f71c9e8e8ff55a745b93b500980288fff53d92f4842bb009ba
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Ona class Instructions def initialize instruction_matcher, target_matcher define_instruction_matcher instruction_matcher define_target_matcher target_matcher end def define_command_string command_string @command_string = command_string end def define_instruction_matcher matcher_regex @instruction_matcher = matcher_regex end def define_target_matcher matcher_regex @target_matcher = matcher_regex end def targets @command_string.scan(@target_matcher) end def instructions @command_string.scan(@instruction_matcher) end def group_targets_by_instruction group = [] chunks = (@command_string.split(@instruction_matcher) - [""]) return group if chunks.size != instructions.size chunks.each_with_index do |instruction_targets, index| instruction_targets = (instruction_targets.scan(@target_matcher) - []) group << { instructions[index] => instruction_targets } end group end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ona-0.4.1 | lib/ona_instructions.rb |
ona-0.4.0 | lib/ona_instructions.rb |
ona-0.3.0 | lib/ona_instructions.rb |
ona-0.2.0 | lib/ona_instructions.rb |