Class: Literal::StringValue

Inherits:
Value
  • Object
show all
Defined in:
lib/literal/string_value.rb

Instance Attribute Summary

Attributes inherited from Value

#value

Instance Method Summary collapse

Methods inherited from Value

#===, #inspect

Constructor Details

#initialize(value) ⇒ StringValue

Returns a new instance of StringValue.



4
5
6
7
8
9
10
11
12
# File 'lib/literal/string_value.rb', line 4

def initialize(value)
	unless String === value
		raise Literal::TypeError.expected(value, to_be_a: String)
	end

	@value = value

	freeze
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/literal/string_value.rb', line 17

def ==(other)
	case other
	when String
		@value == other
	when Literal::StringValue
		@value == other.value
	else
		false
	end
end