Sha256: 3c5c7e71c7f85e60c02aa8cdb07ec228d25c9d4d5f0fdb3462b182dbf8667d45
Contents?: true
Size: 931 Bytes
Versions: 8
Compression:
Stored size: 931 Bytes
Contents
module Vitreous module Share class Element < Mustache def initialize( hash ) @hash = hash meta_methods end def meta_methods @hash.each do |k,v| (class << self; self; end).class_eval do define_method( k.to_sym ) { v } if !method_defined?( k.to_sym ) end end end def collection? @hash['type'] == 'collection' end def item? @hash['type'] == 'item' end def elements @hash['elements'].map { |e| Element.new( e ) } end def collections @hash['elements'].select { |e| e['type'] == 'collection' }.map { |e| Element.new( e ) } end def items @hash['elements'].select { |e| e['type'] == 'item' }.map { |e| Element.new( e ) } end def to_md( text ) RDiscount.new( render( text ) ).to_html end end end end
Version data entries
8 entries across 8 versions & 1 rubygems