class Organismo::Element
Attributes
location[R]
text[R]
Public Class Methods
new(source_item, location)
click to toggle source
# File lib/organismo/element.rb, line 5 def initialize(source_item, location) @text = source_item @location = location end
Public Instance Methods
convert_to_html()
click to toggle source
# File lib/organismo/element.rb, line 40 def convert_to_html raise 'define convert_to_html in subclasses' end
create()
click to toggle source
require and initialize different instance depending on string regex
# File lib/organismo/element.rb, line 12 def create if text.match(/\_QUOTE/) require 'organismo/element/quote' Organismo::Element::Quote.new(text, location) elsif text.match(/\_SRC/) require 'organismo/element/code' Organismo::Element::Code.new(text, location) elsif text.match(/\_EXAMPLE/) require 'organismo/element/example' Organismo::Element::Example.new(text, location) elsif text.match(/\*/) require 'organismo/element/header' Organismo::Element::Header.new(text, location) elsif text.match(/\[\[\S*(\.png)|(\jpg)|(\.jpeg)\]\]/) require 'organismo/element/image' Organismo::Element::Image.new(text, location) elsif text.match(/\[\[\S*\]\]/) require 'organismo/element/link' Organismo::Element::Link.new(text, location) elsif text.match(/\-/) require 'organismo/element/plain_list' Organismo::Element::PlainList.new(text, location) else require 'organismo/element/text' Organismo::Element::Text.new(text, location) end end