Class: Textile2Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/maruku/input_textile2/t2_parser.rb

Constant Summary collapse

Reg =
%r{
	^
	# block name is 1
	([A-Za-z0-9]+)? 
	# style is 2
	(
	 \{     # open bracket
	   ([^\}]+) # style spec is 3   
	 \}     # close bracket
	)?      
	# language is 4
	(\[(\w+)\])? # value is 5
	# class and id 
	(?:
	 \(     # open par
	   (\w+)?   # optional class specification is 6
	   (?:\#(\w+))?  # optional id is 7
	 \)     # close par
	)?      
	# alignment is 8
	(\<|\>|\<\>|\=)?
	# padding 
	(\(+)? # left is 9
	(\)+)? # right is 10
	# filters is 11
	(\|      
		(?:(?:\w+)\|)+
	)?
	# optional final dot is 12
	(\.)?   
	$
}x

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ Textile2Signature

Returns a new instance of Textile2Signature.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/maruku/input_textile2/t2_parser.rb', line 55

def initialize(s)
	if m = Reg.match(s)
		self.block_name = m[1]
		self.style = m[3]
		self.lang = m[4]
		self.css_class = m[6]
		self.css_id = m[7]
		self.text_align = {nil=>nil,'>'=>'right','<'=>'left',
			'<>'=>'center','='=>'justified'}[m[8]]
		self.num_left_pad = m[9] && m[9].size
		self.num_right_pad = m[10] && m[10].size
		self.filters = m[11] && m[11].split('|')
		self.double_dot = m[12] && true
	end
end

Instance Attribute Details

#block_nameObject

or nil



72
73
74
# File 'lib/maruku/input_textile2/t2_parser.rb', line 72

def block_name
  @block_name
end

#css_classObject

or nil



75
76
77
# File 'lib/maruku/input_textile2/t2_parser.rb', line 75

def css_class
  @css_class
end

#css_idObject

or nil



76
77
78
# File 'lib/maruku/input_textile2/t2_parser.rb', line 76

def css_id
  @css_id
end

#double_dotObject

nil or true



81
82
83
# File 'lib/maruku/input_textile2/t2_parser.rb', line 81

def double_dot
  @double_dot
end

#filtersObject

nil [], array of strings



80
81
82
# File 'lib/maruku/input_textile2/t2_parser.rb', line 80

def filters
  @filters
end

#langObject

or nil



74
75
76
# File 'lib/maruku/input_textile2/t2_parser.rb', line 74

def lang
  @lang
end

#num_left_padObject

nil or 1..



78
79
80
# File 'lib/maruku/input_textile2/t2_parser.rb', line 78

def num_left_pad
  @num_left_pad
end

#num_right_padObject

nil or 1..



79
80
81
# File 'lib/maruku/input_textile2/t2_parser.rb', line 79

def num_right_pad
  @num_right_pad
end

#styleObject

or nil



73
74
75
# File 'lib/maruku/input_textile2/t2_parser.rb', line 73

def style
  @style
end

#text_alignObject

‘left’, ‘right’, ‘center’, ‘justified’



77
78
79
# File 'lib/maruku/input_textile2/t2_parser.rb', line 77

def text_align
  @text_align
end