class LoremInlineMacro
Public Instance Methods
is_numeric(input)
click to toggle source
# File lib/starter_web/_plugins/lorem_inline.rb, line 129 def is_numeric(input) return true if input =~ /\A\d+\Z/ false if Float(input) rescue false end
process(parent, target, attributes)
click to toggle source
# File lib/starter_web/_plugins/lorem_inline.rb, line 134 def process parent, target, attributes lorem = Lorem::LoremObject.new method = target.to_sym if lorem.respond_to? method if (attributes.has_key? 'arg') if is_numeric(attributes['arg']) %w(words sentences).include?(target) ? content = lorem.send(method, attributes['arg'].to_i.abs) : nil else %w(word date image).include?(target) ? content = lorem.send(method, attributes['arg']) : nil end %w(sentences).include?(target) ? content.concat(".") : nil %(#{content}) else %w(word sentence date name first_name last_name email).include?(target) ? content = lorem.send(method) : nil %w(sentence).include?(target) ? content.concat(".") : nil %(#{content}) end else warn 'Unknown target for lorem block' nil end end