Class: RubyArguments
- Inherits:
-
Object
show all
- Defined in:
- lib/ruby_arguments.rb,
lib/ruby_arguments/version.rb
Defined Under Namespace
Modules: Exceptions
Classes: NullArguments
Constant Summary
collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ void
81
82
83
84
85
|
# File 'lib/ruby_arguments.rb', line 81
def initialize(*args, **kwargs, &block)
@args = args
@kwargs = kwargs
@block = block
end
|
Instance Attribute Details
#args ⇒ Object
58
59
60
|
# File 'lib/ruby_arguments.rb', line 58
def args
@args
end
|
#block ⇒ Object
72
73
74
|
# File 'lib/ruby_arguments.rb', line 72
def block
@block
end
|
#kwargs ⇒ Object
65
66
67
|
# File 'lib/ruby_arguments.rb', line 65
def kwargs
@kwargs
end
|
Class Method Details
92
93
94
|
# File 'lib/ruby_arguments.rb', line 92
def null_arguments
@null_arguments ||= ::RubyArguments::NullArguments.new
end
|
Instance Method Details
#==(other) ⇒ Boolean?
168
169
170
171
172
173
174
175
176
|
# File 'lib/ruby_arguments.rb', line 168
def ==(other)
return unless other.instance_of?(self.class)
return false if args != other.args
return false if kwargs != other.kwargs
return false if block != other.block
true
end
|
#[](key) ⇒ Object
155
156
157
158
159
160
161
|
# File 'lib/ruby_arguments.rb', line 155
def [](key)
case key
when ::Integer then args[key]
when ::Symbol then kwargs[key]
else raise Exceptions::InvalidKeyType.create(key: key)
end
end
|
#any? ⇒ Booleam
109
110
111
112
113
114
115
|
# File 'lib/ruby_arguments.rb', line 109
def any?
return true if args.any?
return true if kwargs.any?
return true if block
false
end
|
#blank? ⇒ Booleam
145
146
147
|
# File 'lib/ruby_arguments.rb', line 145
def blank?
none?
end
|
#deconstruct ⇒ Array
205
206
207
|
# File 'lib/ruby_arguments.rb', line 205
def deconstruct
[args, kwargs, block]
end
|
#deconstruct_keys(keys) ⇒ Hash
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/ruby_arguments.rb', line 214
def deconstruct_keys(keys)
keys ||= [:args, :kwargs, :block]
keys.each_with_object({}) do |key, hash|
case key
when :args
hash[key] = args
when :kwargs
hash[key] = kwargs
when :block
hash[key] = block
end
end
end
|
#empty? ⇒ Booleam
129
130
131
|
# File 'lib/ruby_arguments.rb', line 129
def empty?
none?
end
|
#eql?(other) ⇒ Boolean?
183
184
185
186
187
188
189
190
191
|
# File 'lib/ruby_arguments.rb', line 183
def eql?(other)
return unless other.instance_of?(self.class)
return false if args != other.args
return false if kwargs != other.kwargs
return false if block != other.block
true
end
|
#hash ⇒ Integer
197
198
199
|
# File 'lib/ruby_arguments.rb', line 197
def hash
[self.class, args, kwargs, block].hash
end
|
#none? ⇒ Booleam
121
122
123
|
# File 'lib/ruby_arguments.rb', line 121
def none?
!any?
end
|
#null_arguments? ⇒ Boolean
101
102
103
|
# File 'lib/ruby_arguments.rb', line 101
def null_arguments?
false
end
|
#present? ⇒ Booleam
137
138
139
|
# File 'lib/ruby_arguments.rb', line 137
def present?
any?
end
|