Class: Pdf::EachItemContext

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/content_evaluator.rb

Overview

Context wrapper for each iteration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, item) ⇒ EachItemContext

Returns a new instance of EachItemContext.



191
192
193
194
# File 'lib/pdf/content_evaluator.rb', line 191

def initialize(parent, item)
  @parent = parent
  @item = item
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



202
203
204
205
206
207
208
209
210
# File 'lib/pdf/content_evaluator.rb', line 202

def method_missing(method, *args, &block)
  if @item.respond_to?(method)
    @item.send(method, *args, &block)
  elsif @item.is_a?(Hash) && (@item.key?(method) || @item.key?(method.to_s))
    @item[method] || @item[method.to_s]
  else
    @parent.send(method, *args, &block)
  end
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



200
201
202
# File 'lib/pdf/content_evaluator.rb', line 200

def item
  @item
end

Instance Method Details

#dataObject



196
197
198
# File 'lib/pdf/content_evaluator.rb', line 196

def data
  @parent.data
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
215
216
# File 'lib/pdf/content_evaluator.rb', line 212

def respond_to_missing?(method, include_private = false)
  @item.respond_to?(method) ||
    (@item.is_a?(Hash) && (@item.key?(method) || @item.key?(method.to_s))) ||
    @parent.respond_to?(method, include_private)
end