Class: RuBBCoder::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/rubbcoder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, opts = {}, &blk) ⇒ Tag

Returns a new instance of Tag.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubbcoder.rb', line 8

def initialize(text, opts = {}, &blk)
  @coder = nil
  @text = text
  @example = opts[:example]
  @decription = opts[:description]
  @block = opts[:block]
  @block = true if @block.nil?
  @front = opts[:front]
  @back = opts[:back] if @block
  @custom = blk
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/rubbcoder.rb', line 6

def block
  @block
end

#coderObject

Returns the value of attribute coder.



5
6
7
# File 'lib/rubbcoder.rb', line 5

def coder
  @coder
end

Class Method Details

.clean_css(css) ⇒ Object



32
33
34
35
# File 'lib/rubbcoder.rb', line 32

def self.clean_css(css)
  css = css.split(";").first
  return css.split("\"").first
end

Instance Method Details

#encode(contents, attribute) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubbcoder.rb', line 20

def encode(contents, attribute)
  attribute.gsub!(/^=/, "") if attribute
  attribute = "" if attribute.nil?
  if @custom
    return @custom.call(contents, attribute, @coder.options)
  elsif @block
    return "#{@front}#{contents}#{@back}"
  else
    return @front
  end
end