Class: Bookit::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/bookit.rb,
lib/bookit/content.rb,
lib/bookit/content/link.rb,
lib/bookit/content/list.rb,
lib/bookit/content/text.rb,
lib/bookit/content/image.rb,
lib/bookit/content/header.rb,
lib/bookit/content/paragraph.rb

Defined Under Namespace

Classes: Generic, Header, Image, Link, List, Paragraph, Text

Constant Summary collapse

TYPES =
{
  paragraph: Content::Paragraph,
  image:     Content::Image,
  header:    Content::Header,
  link:      Content::Link,
  list:      Content::List
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_content, parser) ⇒ Content

Returns a new instance of Content.



26
27
28
29
# File 'lib/bookit/content.rb', line 26

def initialize(raw_content, parser)
  @raw_content = raw_content
  @formatted_content = parser.new.parse(raw_content)
end

Instance Attribute Details

#formatted_contentObject

Returns the value of attribute formatted_content.



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

def formatted_content
  @formatted_content
end

#raw_contentObject (readonly)

Returns the value of attribute raw_content.



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

def raw_content
  @raw_content
end

Instance Method Details

#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



34
35
36
# File 'lib/bookit/content.rb', line 34

def render
  @formatted_content.each &:render
end