Class: MaRuKu::AttributeList

Inherits:
Array show all
Defined in:
lib/maruku/attributes.rb

Instance Method Summary collapse

Methods inherited from Array

#inspect_more

Instance Method Details

#push_class(val) ⇒ Object



51
52
53
54
# File 'lib/maruku/attributes.rb', line 51

def push_class(val);        
  raise "Bad :id #{val.inspect}" if not val
  push [:class,  val] 
end

#push_id(val) ⇒ Object



55
56
57
58
# File 'lib/maruku/attributes.rb', line 55

def push_id(val);           
  raise "Bad :id #{val.inspect}" if not val
  push [:id,  val] 
end

#push_key_val(key, val) ⇒ Object



43
44
45
46
# File 'lib/maruku/attributes.rb', line 43

def push_key_val(key, val); 
  raise "Bad #{key.inspect}=#{val.inspect}" if not key and val
  push [key, val] 
end

#push_ref(ref_id) ⇒ Object



47
48
49
50
# File 'lib/maruku/attributes.rb', line 47

def push_ref(ref_id);       
  raise "Bad :ref #{ref_id.inspect}" if not ref_id
  push [:ref, ref_id] 
end

#to_sObject Also known as: to_md



60
61
62
63
64
65
66
67
68
69
# File 'lib/maruku/attributes.rb', line 60

def to_s
  map do |k,v|
    case k
    when :id;    "#" + v.quote_if_needed
    when :class; "." + v.quote_if_needed
    when :ref;    v.quote_if_needed
    else k.quote_if_needed + "=" + v.quote_if_needed
    end
  end . join(' ')
end