Class: Types::RplString
- Inherits:
-
Object
- Object
- Types::RplString
- Defined in:
- lib/rpl/types/string.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value) ⇒ RplString
constructor
A new instance of RplString.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ RplString
Returns a new instance of RplString.
9 10 11 12 13 14 |
# File 'lib/rpl/types/string.rb', line 9 def initialize( value ) raise RplTypeError unless self.class.can_parse?( value ) # we systematicalyl trim enclosing " @value = value[1..-2] end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/rpl/types/string.rb', line 7 def value @value end |
Class Method Details
.can_parse?(value) ⇒ Boolean
20 21 22 |
# File 'lib/rpl/types/string.rb', line 20 def self.can_parse?( value ) value[0] == '"' && value[-1] == '"' end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 27 |
# File 'lib/rpl/types/string.rb', line 24 def ==( other ) other.class == RplString && other.value == value end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/rpl/types/string.rb', line 16 def to_s "\"#{@value}\"" end |