Class: Nucleo::Models::Tag

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/nucleo/models/tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Tag

Returns a new instance of Tag.



6
7
8
# File 'lib/nucleo/models/tag.rb', line 6

def initialize(attributes={})
  @attributes = attributes
end

Instance Method Details

#<=>(other) ⇒ Object



10
11
12
# File 'lib/nucleo/models/tag.rb', line 10

def <=>(other)
  self.length <=> other.length
end

#content_lengthInteger Also known as: length

Returns the content length

Returns:

  • (Integer)


33
34
35
# File 'lib/nucleo/models/tag.rb', line 33

def content_length
  @attributes['content_length'].to_i
end

#full_tagString Also known as: raw_content

Returns the full tag content

Returns:

  • (String)


17
18
19
# File 'lib/nucleo/models/tag.rb', line 17

def full_tag
  @attributes['full_tag']
end

#snippetString

Returns the HTML wrapped snippet

@todo: Extract this to a view helper

Returns:

  • (String)


43
44
45
# File 'lib/nucleo/models/tag.rb', line 43

def snippet
  "<p><code>%s</code></p>" % [CGI.escapeHTML(self.full_tag)]
end

#tag_contentString Also known as: content

Returns the tag content

Returns:

  • (String)


25
26
27
# File 'lib/nucleo/models/tag.rb', line 25

def tag_content
  @attributes['tag_content']
end