Class: Code::Object::String
Instance Attribute Summary collapse
Instance Method Summary
collapse
#<=>, #==, #[], #[]=, #falsy?, #hash, #key?, #truthy?
Constructor Details
#initialize(string) ⇒ String
Returns a new instance of String.
6
7
8
|
# File 'lib/code/object/string.rb', line 6
def initialize(string)
@raw = string
end
|
Instance Attribute Details
Returns the value of attribute raw.
4
5
6
|
# File 'lib/code/object/string.rb', line 4
def raw
@raw
end
|
Instance Method Details
#call(**args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/code/object/string.rb', line 10
def call(**args)
operator = args.fetch(:operator, nil)
arguments = args.fetch(:arguments, [])
if operator == "to_function"
to_function(arguments)
elsif operator == "+"
plus(arguments)
elsif operator == "reverse"
reverse(arguments)
else
super
end
end
|
37
38
39
|
# File 'lib/code/object/string.rb', line 37
def inspect
raw.inspect
end
|
25
26
27
|
# File 'lib/code/object/string.rb', line 25
def succ
::Code::Object::String.new(raw.succ)
end
|
33
34
35
|
# File 'lib/code/object/string.rb', line 33
def to_s
raw
end
|
29
30
31
|
# File 'lib/code/object/string.rb', line 29
def to_sym
raw.to_sym
end
|