Module: EISCP::Parser::HumanReadableParser
- Defined in:
- lib/eiscp/parser/human_readable_parser.rb
Overview
This module parses a human readable command and returns a Message object
Class Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/eiscp/parser/human_readable_parser.rb', line 8 def self.parse(string) array = string.split(' ') if Dictionary.zones.include? array[0] parsed_zone = array.shift else parsed_zone = Dictionary::DEFAULT_ZONE end command_name = array.shift value_name = array.join(" ") command = Dictionary.command_name_to_command(command_name, parsed_zone) value = Dictionary.command_value_name_to_value(command, value_name) if (command.nil? || value.nil?) return nil end Message.new(command: command, value: value) end |