Class: Quote

Inherits:
PostType show all
Defined in:
lib/turbine-core/types/quote.rb

Constant Summary

Constants inherited from PostType

PostType::DEFAULT_FIELDS, PostType::NON_EDITABLE_FIELDS

Constants included from ClassLevelInheritableAttributes

ClassLevelInheritableAttributes::PRIMITIVES

Instance Attribute Summary

Attributes inherited from PostType

#content

Class Method Summary collapse

Methods inherited from PostType

allow, auto_detect, #blank_attr?, #commit_array, #commit_hash, default, #default_status, #delete_attr, dynamic, #eval_defaults, fields, #fill_default_fields, #generate_slug, #get_attr, #get_attr?, get_pairs, get_pairs_count, #get_string_for, #haml, has_keys?, has_more_than?, has_more_than_one?, has_one_or_more?, has_required?, heading, html, #import, #initialize, markdown, #post_to_trackbacks, preferred_order, preferred_order=, primary, required, #sanitize_content_fields, #save, #send_to_storage, #set_attr, #set_default, #slug_is_unique, special, string_for, #to_html, #to_s, #truncate_slug, #uuid, #valid?

Methods included from ClassLevelInheritableAttributes

#cattr_inheritable, #inherited

Constructor Details

This class inherits a constructor from PostType

Class Method Details

.detect?(text) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/turbine-core/types/quote.rb', line 27

def self.detect?(text)
  pairs = get_pairs(text)
  
  the_quote = pairs.select { |pair| pair.keys.first == :quote }
  the_quote = the_quote.first || {}
  
  markdown = Markdown.new(the_quote[:quote])
  quote_html = markdown.text.blank? ? "" : markdown.to_html.strip
  
  !(text =~ /Quote: (.*)/).blank? || !(quote_html.split("\n").first =~ /^<blockquote(.+)<\/blockquote>$/m).blank?
end