Class: Blockhead::Extractors::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/blockhead/extractors/abstract.rb

Direct Known Subclasses

Block, Enumerable, Proc, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, arg, proc) ⇒ Abstract

Returns a new instance of Abstract.



7
8
9
10
11
# File 'lib/blockhead/extractors/abstract.rb', line 7

def initialize(object, arg, proc)
  @object = object
  @arg = arg
  @proc = proc
end

Instance Attribute Details

#next=(value) ⇒ Object (writeonly)

Sets the attribute next

Parameters:

  • value

    the value to set the attribute next to.



4
5
6
# File 'lib/blockhead/extractors/abstract.rb', line 4

def next=(value)
  @next = value
end

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/blockhead/extractors/abstract.rb', line 5

def object
  @object
end

Instance Method Details

#extractObject



21
22
23
24
25
26
27
# File 'lib/blockhead/extractors/abstract.rb', line 21

def extract
  if valid?
    extract_value
  else
    @next.extract
  end
end

#extract_valueObject



17
18
19
# File 'lib/blockhead/extractors/abstract.rb', line 17

def extract_value
  fail '#extract_value not implemented'
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/blockhead/extractors/abstract.rb', line 13

def valid?
  fail '#valid? not implemented'
end