Class: RubyArguments
- Inherits:
-
Object
show all
- Defined in:
- lib/ruby_arguments.rb,
lib/ruby_arguments/version.rb
Overview
Defined Under Namespace
Modules: Exceptions
Classes: NullArguments
Constant Summary
collapse
- VERSION =
"1.1.0"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ void
114
115
116
117
118
|
# File 'lib/ruby_arguments.rb', line 114
def initialize(*args, **kwargs, &block)
@args = args
@kwargs = kwargs
@block = block
end
|
Instance Attribute Details
#args ⇒ Object
88
89
90
|
# File 'lib/ruby_arguments.rb', line 88
def args
@args
end
|
#block ⇒ Object
104
105
106
|
# File 'lib/ruby_arguments.rb', line 104
def block
@block
end
|
#kwargs ⇒ Object
96
97
98
|
# File 'lib/ruby_arguments.rb', line 96
def kwargs
@kwargs
end
|
Instance Method Details
#==(other) ⇒ Boolean?
230
231
232
233
234
235
236
237
238
|
# File 'lib/ruby_arguments.rb', line 230
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
216
217
218
219
220
221
222
|
# File 'lib/ruby_arguments.rb', line 216
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
165
166
167
168
169
170
171
|
# File 'lib/ruby_arguments.rb', line 165
def any?
return true if args.any?
return true if kwargs.any?
return true if block
false
end
|
#blank? ⇒ Booleam
205
206
207
|
# File 'lib/ruby_arguments.rb', line 205
def blank?
none?
end
|
#deconstruct ⇒ Array
270
271
272
|
# File 'lib/ruby_arguments.rb', line 270
def deconstruct
[args, kwargs, block]
end
|
#deconstruct_keys(keys) ⇒ Hash
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
# File 'lib/ruby_arguments.rb', line 280
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
187
188
189
|
# File 'lib/ruby_arguments.rb', line 187
def empty?
none?
end
|
#eql?(other) ⇒ Boolean?
246
247
248
249
250
251
252
253
254
|
# File 'lib/ruby_arguments.rb', line 246
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
261
262
263
|
# File 'lib/ruby_arguments.rb', line 261
def hash
[self.class, args, kwargs, block].hash
end
|
#none? ⇒ Booleam
178
179
180
|
# File 'lib/ruby_arguments.rb', line 178
def none?
!any?
end
|
#null_arguments? ⇒ Boolean
Also known as:
nil_arguments?
146
147
148
|
# File 'lib/ruby_arguments.rb', line 146
def null_arguments?
false
end
|
#present? ⇒ Booleam
196
197
198
|
# File 'lib/ruby_arguments.rb', line 196
def present?
any?
end
|