Class: IntervalNotation::Segmentation::Segment

Inherits:
Struct
  • Object
show all
Defined in:
lib/interval_notation/segmentation.rb

Overview

Helper class to store a state of a segment

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#intervalObject

Returns the value of attribute interval

Returns:

  • (Object)

    the current value of interval



18
19
20
# File 'lib/interval_notation/segmentation.rb', line 18

def interval
  @interval
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



18
19
20
# File 'lib/interval_notation/segmentation.rb', line 18

def state
  @state
end

Instance Method Details

#inspectObject



27
# File 'lib/interval_notation/segmentation.rb', line 27

def inspect; to_s; end

#to_sObject



19
20
21
22
23
24
25
26
# File 'lib/interval_notation/segmentation.rb', line 19

def to_s
  if state.is_a?(Set) # Set#to_s don't show any content. Quite uninformative
    set_elements = '{' + state.to_a.join(', ') + '}'
    "<#{interval}: #{set_elements}>"
  else
    "<#{interval}: #{state}>"
  end
end