Module: CrazyHarry::FosterModule

Defined in:
lib/crazy_harry/change.rb

Instance Method Summary collapse

Instance Method Details

#foster!Object



68
69
70
71
72
# File 'lib/crazy_harry/change.rb', line 68

def foster!
  if orphaned_li?
    self.replace wrap_li
  end
end

#orphaned_li?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/crazy_harry/change.rb', line 74

def orphaned_li?
  name == 'li' && parent.name !~ /ol|ul/
end

#wrap_liObject



78
79
80
# File 'lib/crazy_harry/change.rb', line 78

def wrap_li
  Nokogiri.make("<ul>#{self}</ul>") 
end