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.0.0"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ void
104
105
106
107
108
|
# File 'lib/ruby_arguments.rb', line 104
def initialize(*args, **kwargs, &block)
@args = args
@kwargs = kwargs
@block = block
end
|
Instance Attribute Details
#args ⇒ Object
78
79
80
|
# File 'lib/ruby_arguments.rb', line 78
def args
@args
end
|
#block ⇒ Object
94
95
96
|
# File 'lib/ruby_arguments.rb', line 94
def block
@block
end
|
#kwargs ⇒ Object
86
87
88
|
# File 'lib/ruby_arguments.rb', line 86
def kwargs
@kwargs
end
|
Instance Method Details
#==(other) ⇒ Boolean?
200
201
202
203
204
205
206
207
208
|
# File 'lib/ruby_arguments.rb', line 200
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
186
187
188
189
190
191
192
|
# File 'lib/ruby_arguments.rb', line 186
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
135
136
137
138
139
140
141
|
# File 'lib/ruby_arguments.rb', line 135
def any?
return true if args.any?
return true if kwargs.any?
return true if block
false
end
|
#blank? ⇒ Booleam
175
176
177
|
# File 'lib/ruby_arguments.rb', line 175
def blank?
none?
end
|
#deconstruct ⇒ Array
240
241
242
|
# File 'lib/ruby_arguments.rb', line 240
def deconstruct
[args, kwargs, block]
end
|
#deconstruct_keys(keys) ⇒ Hash
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
# File 'lib/ruby_arguments.rb', line 250
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
157
158
159
|
# File 'lib/ruby_arguments.rb', line 157
def empty?
none?
end
|
#eql?(other) ⇒ Boolean?
216
217
218
219
220
221
222
223
224
|
# File 'lib/ruby_arguments.rb', line 216
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
231
232
233
|
# File 'lib/ruby_arguments.rb', line 231
def hash
[self.class, args, kwargs, block].hash
end
|
#none? ⇒ Booleam
148
149
150
|
# File 'lib/ruby_arguments.rb', line 148
def none?
!any?
end
|
#null_arguments? ⇒ Boolean
126
127
128
|
# File 'lib/ruby_arguments.rb', line 126
def null_arguments?
false
end
|
#present? ⇒ Booleam
166
167
168
|
# File 'lib/ruby_arguments.rb', line 166
def present?
any?
end
|