Class: HTMLField

Inherits:
TextField show all
Defined in:
lib/yodel/models/core/fields/html_field.rb

Constant Summary

Constants inherited from Field

Field::TYPES

Instance Attribute Summary

Attributes inherited from Field

#name, #options

Instance Method Summary collapse

Methods inherited from StringField

#from_json, #untypecast

Methods inherited from Field

#display?, field_from_type, #from_json, from_options, #include_in_search_keywords?, #index?, #inherited?, #initialize, #method_missing, #numeric?, #required?, #searchable?, #strip_nil?, #to_json, #to_str, #typecast, #unique?, #untypecast, #validate

Constructor Details

This class inherits a constructor from Field

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Field

Instance Method Details

#default_input_typeObject



10
11
12
# File 'lib/yodel/models/core/fields/html_field.rb', line 10

def default_input_type
  :html
end

#search_terms_set(record) ⇒ Object



2
3
4
# File 'lib/yodel/models/core/fields/html_field.rb', line 2

def search_terms_set(record)
  to_text(record.get(name)).gsub(/\W+/, ' ').split
end

#to_text(html) ⇒ Object



6
7
8
# File 'lib/yodel/models/core/fields/html_field.rb', line 6

def to_text(html)
  Hpricot(html.to_s).search('//text()').collect(&:to_s).collect(&:strip).join(' ').strip
end