Class: Kube::Ctl::StringBuilder
- Inherits:
-
Object
- Object
- Kube::Ctl::StringBuilder
show all
- Includes:
- Enumerable
- Defined in:
- lib/kube/ctl/string_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StringBuilder.
22
23
24
|
# File 'lib/kube/ctl/string_builder.rb', line 22
def initialize
@buffer = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &_block) ⇒ Object
34
35
36
37
38
|
# File 'lib/kube/ctl/string_builder.rb', line 34
def method_missing(name, *args, &_block)
tap do
@buffer << [name.to_s, args]
end
end
|
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
20
21
22
|
# File 'lib/kube/ctl/string_builder.rb', line 20
def buffer
@buffer
end
|
Instance Method Details
#-(other) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/kube/ctl/string_builder.rb', line 52
def -(other)
tap do
case other
when MethodCallToken
@buffer << [other.base.to_s, []]
@buffer << :dash
@buffer << [other.name.to_s, other.args]
else
@buffer << [other.to_s, []] unless other.is_a?(StringBuilder)
@buffer << :dash
end
end
end
|
#/(_other) ⇒ Object
46
47
48
49
50
|
# File 'lib/kube/ctl/string_builder.rb', line 46
def /(_other)
tap do
@buffer << :slash
end
end
|
#call(token) ⇒ Object
40
41
42
43
44
|
# File 'lib/kube/ctl/string_builder.rb', line 40
def call(token)
tap do
@buffer << [token.to_s, []]
end
end
|
#each {|@buffer| ... } ⇒ Object
26
27
28
|
# File 'lib/kube/ctl/string_builder.rb', line 26
def each
yield @buffer
end
|
#respond_to_missing?(_name, _include_private = false) ⇒ Boolean
30
31
32
|
# File 'lib/kube/ctl/string_builder.rb', line 30
def respond_to_missing?(_name, _include_private = false)
true
end
|