Class: Enumerator
- Defined in:
- lib/core/facets/to_hash.rb,
lib/core/facets/enumerator.rb,
lib/core/facets/enumerator/fx.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Yielder
Instance Method Summary collapse
- #fx ⇒ Object
-
#to_h(mode = nil) ⇒ Object
Convert an Enumerator object into a hash.
-
#to_h_assoc ⇒ Object
This is equivalent to Array#to_h_assoc.
-
#to_h_auto ⇒ Object
This is equivalent to Array#to_h_auto.
-
#to_h_flat ⇒ Object
This is equivalent to Array#to_h_flat.
-
#to_h_multi ⇒ Object
This is equivalent to Array#to_h_multi.
-
#to_h_splat ⇒ Object
This is equivalent to Array#to_h_splat.
Instance Method Details
#fx ⇒ Object
15 16 17 |
# File 'lib/core/facets/enumerator/fx.rb', line 15 def fx Functor.new(&method(:fx_send).to_proc) end |
#to_h(mode = nil) ⇒ Object
Convert an Enumerator object into a hash. This is equivalent to Array#to_h.
e1 = [[1,:a],[2,:b],[3,:c]].to_enum
e1.to_h #=> { 1=>:a, 2=>:b, 3=>:c }
e2 = [1,2,3,4,5].to_enum
e2.to_h #=> {5=>nil, 1=>2, 3=>4}
e3 = [1,2,1,3,1,5].to_enum
e3.to_h #=> {1=>5}
CREDIT: Sandor Szücs
289 290 291 |
# File 'lib/core/facets/to_hash.rb', line 289 def to_h(mode=nil) to_a.to_h(mode) end |
#to_h_assoc ⇒ Object
This is equivalent to Array#to_h_assoc.
313 314 315 |
# File 'lib/core/facets/to_hash.rb', line 313 def to_h_assoc to_a.to_h_assoc end |
#to_h_auto ⇒ Object
This is equivalent to Array#to_h_auto.
295 296 297 |
# File 'lib/core/facets/to_hash.rb', line 295 def to_h_auto to_a.to_h_auto end |
#to_h_flat ⇒ Object
This is equivalent to Array#to_h_flat.
307 308 309 |
# File 'lib/core/facets/to_hash.rb', line 307 def to_h_flat to_a.to_h_flat end |
#to_h_multi ⇒ Object
This is equivalent to Array#to_h_multi.
319 320 321 |
# File 'lib/core/facets/to_hash.rb', line 319 def to_h_multi to_a.to_h_multi end |
#to_h_splat ⇒ Object
This is equivalent to Array#to_h_splat.
301 302 303 |
# File 'lib/core/facets/to_hash.rb', line 301 def to_h_splat to_a.to_h_splat end |