Class: Progress::WithProgress

Inherits:
Object
  • Object
show all
Defined in:
lib/progress/with_progress.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, title) ⇒ WithProgress

Returns a new instance of WithProgress.



6
7
8
9
# File 'lib/progress/with_progress.rb', line 6

def initialize(object, title)
  @object = Progress::Enhancer.new(object)
  @title = title
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



15
16
17
18
19
# File 'lib/progress/with_progress.rb', line 15

def method_missing(method, *args, &block)
  Progress.start(title, object.length) do
    object.send(method, *args, &block)
  end
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/progress/with_progress.rb', line 5

def object
  @object
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/progress/with_progress.rb', line 5

def title
  @title
end

Instance Method Details

#with_progress(title) ⇒ Object



11
12
13
# File 'lib/progress/with_progress.rb', line 11

def with_progress(title)
  self
end