Class: Prune::PObjects::PLiteralString

Inherits:
Base
  • Object
show all
Defined in:
lib/prune/p_objects/p_literal_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#indent!, #outdent!, #space, #value_to_s

Constructor Details

#initialize(string) ⇒ PLiteralString

Returns a new instance of PLiteralString.



8
9
10
11
12
# File 'lib/prune/p_objects/p_literal_string.rb', line 8

def initialize(string)
  raise PLiteralStringTypeError unless
    string.instance_of?(String)
  @string = string
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



6
7
8
# File 'lib/prune/p_objects/p_literal_string.rb', line 6

def string
  @string
end

Instance Method Details

#==(value) ⇒ Object



14
15
16
17
# File 'lib/prune/p_objects/p_literal_string.rb', line 14

def ==(value)
  false unless value.instance_of?(self.class)
  @string == value.string
end

#to_sObject



19
20
21
# File 'lib/prune/p_objects/p_literal_string.rb', line 19

def to_s
  "(#{@string})"
end