Class: Types::RplProgram
- Inherits:
-
Object
- Object
- Types::RplProgram
- Defined in:
- lib/rpl/types/program.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) ⇒ RplProgram
constructor
A new instance of RplProgram.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ RplProgram
Returns a new instance of RplProgram.
7 8 9 10 11 12 |
# File 'lib/rpl/types/program.rb', line 7 def initialize( value ) raise RplTypeError unless self.class.can_parse?( value ) # we systematicalyl trim enclosing « » @value = value[2..-3] # TODO: parse each element ? end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/rpl/types/program.rb', line 5 def value @value end |
Class Method Details
.can_parse?(value) ⇒ Boolean
18 19 20 |
# File 'lib/rpl/types/program.rb', line 18 def self.can_parse?( value ) value.length > 4 && value[0..1] == '« ' && value[-2..-1] == ' »' && !value[2..-3].strip.empty? end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 |
# File 'lib/rpl/types/program.rb', line 22 def ==( other ) other.class == RplProgram and other.value == value end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/rpl/types/program.rb', line 14 def to_s "« #{@value} »" end |