Class: Component

Inherits:
Object
  • Object
show all
Defined in:
app/models/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'app/models/component.rb', line 4

def description
  @description
end

#exampleObject

Returns the value of attribute example.



4
5
6
# File 'app/models/component.rb', line 4

def example
  @example
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'app/models/component.rb', line 4

def name
  @name
end

#sectionObject

Returns the value of attribute section.



4
5
6
# File 'app/models/component.rb', line 4

def section
  @section
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'app/models/component.rb', line 4

def source
  @source
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'app/models/component.rb', line 4

def url
  @url
end

Instance Method Details

#display_descriptionObject



6
7
8
# File 'app/models/component.rb', line 6

def display_description
  RDiscount.new(self.description, :smart, :filter_html).to_html.html_safe if self.description
end

#display_exampleObject



10
11
12
# File 'app/models/component.rb', line 10

def display_example
  ERB.new(example).result if self.example
end

#slugObject



14
15
16
# File 'app/models/component.rb', line 14

def slug
  self.name.downcase.gsub(/[^a-z1-9]+/, '-').chomp('-')
end