Class: LineType

Inherits:
Struct
  • Object
show all
Defined in:
lib/aml/line_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#regexObject

Returns the value of attribute regex

Returns:

  • (Object)

    the current value of regex



1
2
3
# File 'lib/aml/line_type.rb', line 1

def regex
  @regex
end

Instance Method Details

#attributes(match) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/aml/line_type.rb', line 5

def attributes(match)
	begin
		stringHashToHash(match[:attributes])
	rescue Exception => e
		{:abstract_markup_language_exception=>true}
	end
end

#bundle(match) ⇒ Object



12
13
14
# File 'lib/aml/line_type.rb', line 12

def bundle(match)
	match[:bundle].to_s
end

#class(match) ⇒ Object



15
16
17
# File 'lib/aml/line_type.rb', line 15

def class(match)
	match[:class].to_s.split('.').join(' ').strip!
end

#close(match) ⇒ Object



33
34
35
36
37
# File 'lib/aml/line_type.rb', line 33

def close(match)
	# => </tag> /self> >
	type = %w(tag self none)
	type[match[:close].to_s.length]
end

#id_first(match) ⇒ Object



27
28
29
# File 'lib/aml/line_type.rb', line 27

def id_first(match)
	match[:id_first].to_s
end

#id_last(match) ⇒ Object



30
31
32
# File 'lib/aml/line_type.rb', line 30

def id_last(match)
	match[:id_last].to_s
end

#match?(string) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/aml/line_type.rb', line 2

def match?(string)
	string.match(regex)
end

#name(match) ⇒ Object



18
19
20
# File 'lib/aml/line_type.rb', line 18

def name(match)
	match[:name].to_s
end

#stringHashToHash(string) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/aml/line_type.rb', line 41

def stringHashToHash(string)
	hash = {}
	regex = /:(?<name>\w+)\s?=>\s?(?<hash>{(.+?)?}|(?<quote>'|")(?<value>.+?)??\k<quote>)/
	names = regex.names
	if string != nil
		string.scan(regex){|match|
			thisHash = Hash[names.zip(match)]
			if thisHash["hash"].to_s[0] == "{"
				hash[thisHash["name"].to_sym] = stringHashToHash(thisHash["hash"])
			else
				hash[thisHash["name"].to_sym] = thisHash["value"].to_s
			end
		}
	end
	hash
end

#tab_reset(match) ⇒ Object



38
39
40
# File 'lib/aml/line_type.rb', line 38

def tab_reset(match)
	match[:tab_reset].to_s
end

#text(match) ⇒ Object



21
22
23
# File 'lib/aml/line_type.rb', line 21

def text(match)
	match[:text].to_s.strip!
end

#value(match) ⇒ Object



24
25
26
# File 'lib/aml/line_type.rb', line 24

def value(match)
	match[:value].to_s
end