Class: CodeTypeRefiner

Inherits:
TypeRefiner show all
Defined in:
lib/notroff/type_refiner.rb

Instance Method Summary collapse

Methods inherited from TypeRefiner

#next_paragraph_type, #previous_paragraph_type, #process

Constructor Details

#initialize(base_type = :code, first_type = :first_code, middle_type = :middle_code, end_type = :end_code, single_type = middle_type) ⇒ CodeTypeRefiner

Returns a new instance of CodeTypeRefiner.



31
32
33
34
35
36
37
38
# File 'lib/notroff/type_refiner.rb', line 31

def initialize(base_type=:code, first_type=:first_code, middle_type=:middle_code,
  end_type=:end_code, single_type=middle_type)
  @base_type = base_type
  @first_type = first_type
  @middle_type = middle_type
  @end_type = end_type
  @single_type = single_type
end

Instance Method Details

#type_for(previous_type, type, next_type) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/notroff/type_refiner.rb', line 40

def type_for( previous_type, type, next_type )
  Logger.log "code type for [#{previous_type}] [#{type}] [#{next_type}]"
  if type != @base_type
    new_type = type

  elsif previous_type ==@base_type and next_type == @base_type
    new_type = @middle_type

  elsif previous_type == @base_type
    new_type = @end_type

  elsif next_type == @base_type
    new_type = @first_type

  else
    new_type = @single_type
  end

  Logger.log("new type: #{new_type}")
  new_type
end