Class: BEL::Script::Statement

Inherits:
Struct
  • Object
show all
Defined in:
lib/bel/parse_objects.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotationsObject

Returns the value of attribute annotations

Returns:

  • the current value of annotations



74
75
76
# File 'lib/bel/parse_objects.rb', line 74

def annotations
  @annotations
end

#commentObject

Returns the value of attribute comment

Returns:

  • the current value of comment



74
75
76
# File 'lib/bel/parse_objects.rb', line 74

def comment
  @comment
end

#objectObject

Returns the value of attribute object

Returns:

  • the current value of object



74
75
76
# File 'lib/bel/parse_objects.rb', line 74

def object
  @object
end

#relObject

Returns the value of attribute rel

Returns:

  • the current value of rel



74
75
76
# File 'lib/bel/parse_objects.rb', line 74

def rel
  @rel
end

#subjectObject

Returns the value of attribute subject

Returns:

  • the current value of subject



74
75
76
# File 'lib/bel/parse_objects.rb', line 74

def subject
  @subject
end

Instance Method Details

#nested?Boolean

Returns:



81
82
83
# File 'lib/bel/parse_objects.rb', line 81

def nested?
  object.is_a? Statement
end

#simple?Boolean

Returns:



78
79
80
# File 'lib/bel/parse_objects.rb', line 78

def simple?
  object.is_a? Term
end

#subject_only?Boolean

Returns:



75
76
77
# File 'lib/bel/parse_objects.rb', line 75

def subject_only?
  !rel
end

#to_sObject



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/bel/parse_objects.rb', line 84

def to_s
  lbl = case
  when subject_only?
    subject.to_s
  when simple?
    "#{subject.to_s} #{rel} #{object.to_s}"
  when nested?
    "#{subject.to_s} #{rel} (#{object.to_s})"
  end
  comment ? lbl + ' //' + comment : lbl
end