Class: PGN::MoveText
- Inherits:
-
Object
- Object
- PGN::MoveText
- Defined in:
- lib/pgn/game.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#notation ⇒ Object
Returns the value of attribute notation.
-
#variations ⇒ Object
Returns the value of attribute variations.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #clean_text(text) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(notation, annotation = nil, comment = nil, variations = []) ⇒ MoveText
constructor
A new instance of MoveText.
- #to_s ⇒ Object
Constructor Details
#initialize(notation, annotation = nil, comment = nil, variations = []) ⇒ MoveText
Returns a new instance of MoveText.
9 10 11 12 13 14 |
# File 'lib/pgn/game.rb', line 9 def initialize(notation, annotation = nil, comment = nil, variations = []) @notation = notation @annotation = annotation @comment = clean_text(comment) @variations = variations end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
7 8 9 |
# File 'lib/pgn/game.rb', line 7 def annotation @annotation end |
#comment ⇒ Object
Returns the value of attribute comment.
7 8 9 |
# File 'lib/pgn/game.rb', line 7 def comment @comment end |
#notation ⇒ Object
Returns the value of attribute notation.
7 8 9 |
# File 'lib/pgn/game.rb', line 7 def notation @notation end |
#variations ⇒ Object
Returns the value of attribute variations.
7 8 9 |
# File 'lib/pgn/game.rb', line 7 def variations @variations end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/pgn/game.rb', line 16 def ==(other) to_s == other.to_s end |
#clean_text(text) ⇒ Object
32 33 34 |
# File 'lib/pgn/game.rb', line 32 def clean_text(text) text&.gsub(/{(.*)}/, '\1')&.gsub(/\s+/, ' ')&.strip end |
#eql?(other) ⇒ Boolean
20 21 22 |
# File 'lib/pgn/game.rb', line 20 def eql?(other) self == other end |
#hash ⇒ Object
24 25 26 |
# File 'lib/pgn/game.rb', line 24 def hash @notation.hash end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/pgn/game.rb', line 28 def to_s @notation end |