Class: Bookit::Content::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/bookit/content/generic.rb

Direct Known Subclasses

Header, Image, Link, List, Paragraph, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generic

Content can always take options. These can usually be used to add additional formatting information for the Emitters



7
8
9
# File 'lib/bookit/content/generic.rb', line 7

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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/bookit/content/generic.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#is_type?(sym) ⇒ Boolean

returns true if this symbol is tied to the class type

Returns:

  • (Boolean)


24
25
26
# File 'lib/bookit/content/generic.rb', line 24

def is_type? sym
  self.class == Content::TYPES[sym]
end

#renderObject

#render for any Content object should always return a string it is also possible to pass a block to render actions so that you can fine-tune the content output from your Emitters



14
15
16
# File 'lib/bookit/content/generic.rb', line 14

def render
  inspect
end

#typeObject

gives us an easy to compare type symbol



19
20
21
# File 'lib/bookit/content/generic.rb', line 19

def type
  self.class.to_s.split('::').last.downcase.to_sym
end