Class: Terrafying::Ref
- Inherits:
-
Object
show all
- Defined in:
- lib/terrafying/generator.rb
Instance Method Summary
collapse
Instance Method Details
#<=>(other) ⇒ Object
51
52
53
|
# File 'lib/terrafying/generator.rb', line 51
def <=>(other)
to_s <=> other.to_s
end
|
#==(other) ⇒ Object
55
56
57
|
# File 'lib/terrafying/generator.rb', line 55
def ==(other)
to_s == other.to_s
end
|
#[](key) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/terrafying/generator.rb', line 59
def [](key)
if key.is_a? Numeric
IndexRef.new(ref: self, idx: key)
else
AttributeRef.new(ref: self, key: key)
end
end
|
#[]=(_k, _v) ⇒ Object
67
68
69
|
# File 'lib/terrafying/generator.rb', line 67
def []=(_k, _v)
raise "You can't set a value this way"
end
|
#downcase ⇒ Object
19
20
21
|
# File 'lib/terrafying/generator.rb', line 19
def downcase
fn_call('lower')
end
|
#fn_call(fn, *args) ⇒ Object
14
15
16
17
|
# File 'lib/terrafying/generator.rb', line 14
def fn_call(fn, *args)
args = [ARG_PLACEHOLDER] if args.empty?
FnRef.new(fn: fn, args: args, ref: self)
end
|
#realise ⇒ Object
39
40
41
|
# File 'lib/terrafying/generator.rb', line 39
def realise
''
end
|
#slice(idx, length = 0) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/terrafying/generator.rb', line 31
def slice(idx, length = 0)
if length != 0
fn_call('slice', ARG_PLACEHOLDER, idx, idx + length)
else
fn_call('element', ARG_PLACEHOLDER, idx)
end
end
|
#split(separator) ⇒ Object
27
28
29
|
# File 'lib/terrafying/generator.rb', line 27
def split(separator)
fn_call('split', separator, ARG_PLACEHOLDER)
end
|
#strip ⇒ Object
23
24
25
|
# File 'lib/terrafying/generator.rb', line 23
def strip
fn_call('trimspace')
end
|
#to_s ⇒ Object
43
44
45
|
# File 'lib/terrafying/generator.rb', line 43
def to_s
"${#{realise}}"
end
|
#to_str ⇒ Object
47
48
49
|
# File 'lib/terrafying/generator.rb', line 47
def to_str
to_s
end
|