Class: AsciiTree::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii_tree/word.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity:, value:, start_coordinate:, end_coordinate:) ⇒ Word

Returns a new instance of Word.



5
6
7
8
9
10
# File 'lib/ascii_tree/word.rb', line 5

def initialize(identity:, value:, start_coordinate:, end_coordinate:)
  @identity         = identity
  @value            = value
  @start_coordinate = start_coordinate
  @end_coordinate   = end_coordinate
end

Instance Attribute Details

#end_coordinateObject (readonly)

Returns the value of attribute end_coordinate.



3
4
5
# File 'lib/ascii_tree/word.rb', line 3

def end_coordinate
  @end_coordinate
end

#identityObject (readonly)

Returns the value of attribute identity.



3
4
5
# File 'lib/ascii_tree/word.rb', line 3

def identity
  @identity
end

#start_coordinateObject (readonly)

Returns the value of attribute start_coordinate.



3
4
5
# File 'lib/ascii_tree/word.rb', line 3

def start_coordinate
  @start_coordinate
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/ascii_tree/word.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
15
16
17
# File 'lib/ascii_tree/word.rb', line 12

def ==(other)
  identity == other.identity &&
    value == other.value &&
    start_coordinate == other.start_coordinate &&
    end_coordinate == other.end_coordinate
end

#include?(coordinate) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ascii_tree/word.rb', line 19

def include?(coordinate)
  same_line?(coordinate.y) && inside?(coordinate.x)
end