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
24
25
|
# 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 == "*"
multiplication(arguments)
elsif operator == "reverse"
reverse(arguments)
else
super
end
end
|
39
40
41
|
# File 'lib/code/object/string.rb', line 39
def inspect
raw.inspect
end
|
27
28
29
|
# File 'lib/code/object/string.rb', line 27
def succ
::Code::Object::String.new(raw.succ)
end
|
35
36
37
|
# File 'lib/code/object/string.rb', line 35
def to_s
raw
end
|
31
32
33
|
# File 'lib/code/object/string.rb', line 31
def to_sym
raw.to_sym
end
|