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:

  • (Object)

    the current value of annotations



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

def annotations
  @annotations
end

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



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

def comment
  @comment
end

#objectObject

Returns the value of attribute object

Returns:

  • (Object)

    the current value of object



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

def object
  @object
end

#relObject

Returns the value of attribute rel

Returns:

  • (Object)

    the current value of rel



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

def rel
  @rel
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



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

def subject
  @subject
end

Instance Method Details

#nested?Boolean

Returns:

  • (Boolean)


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

def nested?
  object.is_a? Statement
end

#simple?Boolean

Returns:

  • (Boolean)


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

def simple?
  object.is_a? Term
end

#subject_only?Boolean

Returns:

  • (Boolean)


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

def subject_only?
  !rel
end

#to_sObject



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

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