Module: Tumblargh::Renderer
- Defined in:
- lib/tumblargh/renderer.rb,
lib/tumblargh/renderer/tag.rb,
lib/tumblargh/renderer/base.rb,
lib/tumblargh/renderer/blocks.rb,
lib/tumblargh/renderer/literal.rb,
lib/tumblargh/renderer/document.rb,
lib/tumblargh/renderer/blocks/base.rb,
lib/tumblargh/renderer/blocks/chat.rb,
lib/tumblargh/renderer/blocks/tags.rb,
lib/tumblargh/renderer/blocks/audio.rb,
lib/tumblargh/renderer/blocks/dates.rb,
lib/tumblargh/renderer/blocks/notes.rb,
lib/tumblargh/renderer/blocks/posts.rb,
lib/tumblargh/renderer/blocks/answer.rb,
lib/tumblargh/renderer/blocks/reblogs.rb,
lib/tumblargh/renderer/blocks/photoset.rb,
lib/tumblargh/renderer/blocks/navigation.rb
Defined Under Namespace
Modules: Blocks Classes: Base, ColorTag, CustomTag, Document, FontTag, ImageTag, LangTag, Literal, Tag, TextTag
Class Method Summary collapse
Class Method Details
.factory(node, context, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tumblargh/renderer.rb', line 12 def self.factory(node, context, = {}) args = [] base = node.first.to_s if base == 'Block' block_name = node[1] if block_name[0..1] == 'If' if block_name[2..4] == 'Not' args << block_name[5..block_name.size] block_name = 'InverseBoolean' else args << block_name[2..block_name.size] block_name = 'Boolean' end elsif n_post = block_name.match(/Post(\d+)/) block_name = 'NumberedPost' args << n_post[1].to_i end base = "Blocks::#{ block_name }" end klass_name = "Tumblargh::Renderer::#{ base }" begin klass = klass_name.constantize klass.new(node, context, , *args) rescue NameError => e puts "WARNING: Unsupported block `#{ klass_name }`" end end |