Module: ActiveSupport::CoreExtensions::Range::BlocklessStep
- Included in:
- Range
- Defined in:
- lib/active_support/core_ext/range/blockless_step.rb
Overview
Return an array when step is called without a block.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
6 7 8 |
# File 'lib/active_support/core_ext/range/blockless_step.rb', line 6 def self.included(base) #:nodoc: base.alias_method_chain :step, :blockless end |
Instance Method Details
#step_with_blockless(value = 1, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/active_support/core_ext/range/blockless_step.rb', line 11 def step_with_blockless(value = 1, &block) if block_given? step_without_blockless(value, &block) else [].tap do |array| step_without_blockless(value) { |step| array << step } end end end |