Class: Adhearsion::Call::Variables::Parser
- Defined in:
- lib/adhearsion/voip/call.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
- .coerce_variables(variables) ⇒ Object
- .parse(*args, &block) ⇒ Object
- .separate_line_into_key_value_pair(line) ⇒ Object
Instance Method Summary collapse
-
#initialize(io) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(io) ⇒ Parser
Returns a new instance of Parser.
465 466 467 468 |
# File 'lib/adhearsion/voip/call.rb', line 465 def initialize(io) @io = io @lines = [] end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
464 465 466 |
# File 'lib/adhearsion/voip/call.rb', line 464 def io @io end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
464 465 466 |
# File 'lib/adhearsion/voip/call.rb', line 464 def lines @lines end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
464 465 466 |
# File 'lib/adhearsion/voip/call.rb', line 464 def variables @variables end |
Class Method Details
.coerce_variables(variables) ⇒ Object
453 454 455 456 457 |
# File 'lib/adhearsion/voip/call.rb', line 453 def coerce_variables(variables) Coercions::COERCION_ORDER.inject(variables) do |tmp_variables, coercing_method_name| Coercions.send(coercing_method_name, tmp_variables) end end |
.parse(*args, &block) ⇒ Object
447 448 449 450 451 |
# File 'lib/adhearsion/voip/call.rb', line 447 def parse(*args, &block) new(*args, &block).tap do |parser| parser.parse end end |
.separate_line_into_key_value_pair(line) ⇒ Object
459 460 461 |
# File 'lib/adhearsion/voip/call.rb', line 459 def separate_line_into_key_value_pair(line) line.match(/^([^:]+):(?:\s?(.+)|$)/).captures end |
Instance Method Details
#parse ⇒ Object
470 471 472 473 474 |
# File 'lib/adhearsion/voip/call.rb', line 470 def parse extract_variable_lines_from_io initialize_variables_as_hash_from_lines @variables = self.class.coerce_variables(variables) end |