Class: MaRuKu::AttributeList

Inherits:
Array
  • Object
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



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

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

#push_id(val) ⇒ Object



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

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

#push_key_val(key, val) ⇒ Object



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

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



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

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



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

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