Class: Adhearsion::Call::Variables::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/voip/call.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#ioObject (readonly)

Returns the value of attribute io.



463
464
465
# File 'lib/adhearsion/voip/call.rb', line 463

def io
  @io
end

#linesObject (readonly)

Returns the value of attribute lines.



463
464
465
# File 'lib/adhearsion/voip/call.rb', line 463

def lines
  @lines
end

#variablesObject (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

#parseObject



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