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.
464 465 466 467 |
# File 'lib/adhearsion/voip/call.rb', line 464 def initialize(io) @io = io @lines = [] end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
463 464 465 |
# File 'lib/adhearsion/voip/call.rb', line 463 def io @io end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
463 464 465 |
# File 'lib/adhearsion/voip/call.rb', line 463 def lines @lines end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
463 464 465 |
# File 'lib/adhearsion/voip/call.rb', line 463 def variables @variables end |
Class Method Details
.coerce_variables(variables) ⇒ Object
452 453 454 455 456 |
# File 'lib/adhearsion/voip/call.rb', line 452 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
446 447 448 449 450 |
# File 'lib/adhearsion/voip/call.rb', line 446 def parse(*args, &block) new(*args, &block).tap do |parser| parser.parse end end |
.separate_line_into_key_value_pair(line) ⇒ Object
458 459 460 |
# File 'lib/adhearsion/voip/call.rb', line 458 def separate_line_into_key_value_pair(line) line.match(/^([^:]+):\s?(.+)/).captures end |
Instance Method Details
#parse ⇒ Object
469 470 471 472 473 |
# File 'lib/adhearsion/voip/call.rb', line 469 def parse extract_variable_lines_from_io initialize_variables_as_hash_from_lines @variables = self.class.coerce_variables(variables) end |