Class: OpenBEL::Routes::Expressions::BELSerializationTransform

Inherits:
Object
  • Object
show all
Includes:
BEL::LibBEL
Defined in:
app/openbel/api/routes/expressions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBELSerializationTransform

Returns a new instance of BELSerializationTransform.



431
432
433
# File 'app/openbel/api/routes/expressions.rb', line 431

def initialize
  @bel_string = ""
end

Instance Attribute Details

#bel_stringObject (readonly)

Returns the value of attribute bel_string.



429
430
431
# File 'app/openbel/api/routes/expressions.rb', line 429

def bel_string
  @bel_string
end

Instance Method Details

#after(ast_node) ⇒ Object



475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'app/openbel/api/routes/expressions.rb', line 475

def after(ast_node)
  if ast_node.is_a?(BelAstNodeToken)
    case ast_node.token_type
    when :BEL_TOKEN_STATEMENT
    when :BEL_TOKEN_SUBJECT
    when :BEL_TOKEN_OBJECT
    when :BEL_TOKEN_REL
    when :BEL_TOKEN_TERM
      @bel_string.concat(')')
    when :BEL_TOKEN_ARG
    when :BEL_TOKEN_NV
    end
  end
end

#between(ast_node) ⇒ Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'app/openbel/api/routes/expressions.rb', line 460

def between(ast_node)
  if ast_node.is_a?(BelAstNodeToken)
    case ast_node.token_type
    when :BEL_TOKEN_STATEMENT
    when :BEL_TOKEN_SUBJECT
    when :BEL_TOKEN_OBJECT
    when :BEL_TOKEN_REL
    when :BEL_TOKEN_TERM
    when :BEL_TOKEN_ARG
      token_arg(ast_node)
    when :BEL_TOKEN_NV
    end
  end
end

#call(ast_node) ⇒ Object



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'app/openbel/api/routes/expressions.rb', line 435

def call(ast_node)
  if ast_node.is_a?(BelAstNodeToken)
    case ast_node.token_type
    when :BEL_TOKEN_STATEMENT
    when :BEL_TOKEN_SUBJECT
    when :BEL_TOKEN_OBJECT
    when :BEL_TOKEN_REL
    when :BEL_TOKEN_TERM
    when :BEL_TOKEN_ARG
    when :BEL_TOKEN_NV
    end
  else
    case ast_node.value_type
    when :BEL_VALUE_FX
      function(ast_node.value)
    when :BEL_VALUE_REL
      relationship(ast_node.value)
    when :BEL_VALUE_PFX
      namespace_prefix(ast_node.value)
    when :BEL_VALUE_VAL
      namespace_value(ast_node.value)
    end
  end
end