duxml 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/validate_xml +30 -30
- data/lib/duxml.rb +76 -76
- data/lib/duxml/doc.rb +108 -91
- data/lib/duxml/doc/element.rb +250 -250
- data/lib/duxml/doc/lazy_ox.rb +167 -167
- data/lib/duxml/doc/node_set.rb +38 -38
- data/lib/duxml/meta.rb +72 -72
- data/lib/duxml/meta/grammar.rb +133 -133
- data/lib/duxml/meta/grammar/pattern.rb +111 -111
- data/lib/duxml/meta/grammar/pattern/attr_name_pattern.rb +36 -36
- data/lib/duxml/meta/grammar/pattern/attr_val_pattern.rb +36 -36
- data/lib/duxml/meta/grammar/pattern/child_pattern.rb +60 -60
- data/lib/duxml/meta/grammar/pattern/text_pattern.rb +31 -31
- data/lib/duxml/meta/grammar/pattern_maker.rb +68 -68
- data/lib/duxml/meta/grammar/relax_ng.rb +39 -39
- data/lib/duxml/meta/grammar/relax_ng/attrs_rule.rb +58 -58
- data/lib/duxml/meta/grammar/relax_ng/children_rule.rb +82 -82
- data/lib/duxml/meta/grammar/relax_ng/value_rule.rb +44 -44
- data/lib/duxml/meta/grammar/rule.rb +58 -58
- data/lib/duxml/meta/grammar/rule/attrs_rule.rb +77 -77
- data/lib/duxml/meta/grammar/rule/children_rule.rb +135 -135
- data/lib/duxml/meta/grammar/rule/text_rule.rb +39 -39
- data/lib/duxml/meta/grammar/rule/value_rule.rb +110 -110
- data/lib/duxml/meta/grammar/spreadsheet.rb +34 -34
- data/lib/duxml/meta/history.rb +88 -88
- data/lib/duxml/meta/history/add.rb +30 -30
- data/lib/duxml/meta/history/change.rb +70 -70
- data/lib/duxml/meta/history/change_attr.rb +33 -33
- data/lib/duxml/meta/history/change_text.rb +32 -32
- data/lib/duxml/meta/history/error.rb +24 -24
- data/lib/duxml/meta/history/new_attr.rb +32 -32
- data/lib/duxml/meta/history/new_text.rb +36 -36
- data/lib/duxml/meta/history/qualify_error.rb +21 -21
- data/lib/duxml/meta/history/remove.rb +27 -27
- data/lib/duxml/meta/history/undo.rb +23 -23
- data/lib/duxml/meta/history/validate_error.rb +20 -20
- data/lib/duxml/reportable.rb +28 -28
- data/lib/duxml/ruby_ext/fixnum.rb +55 -55
- data/lib/duxml/ruby_ext/module.rb +11 -11
- data/lib/duxml/ruby_ext/object.rb +13 -13
- data/lib/duxml/ruby_ext/regexp.rb +19 -19
- data/lib/duxml/ruby_ext/string.rb +37 -37
- data/lib/duxml/saxer.rb +75 -75
- metadata +12 -12
@@ -1,37 +1,37 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/change')
|
4
|
-
|
5
|
-
module Duxml
|
6
|
-
module NewText; end
|
7
|
-
|
8
|
-
# created when object had no children or text and text has been added
|
9
|
-
class NewTextClass < ChangeClass
|
10
|
-
include NewText
|
11
|
-
|
12
|
-
# @param _subject [Duxml::Element] doc that has gained new text
|
13
|
-
# @param _index [Fixnum] index of new text node
|
14
|
-
def initialize(_subject, _str, _index)
|
15
|
-
super _subject
|
16
|
-
@index, @str = _index, _str
|
17
|
-
end
|
18
|
-
|
19
|
-
attr_reader :index, :str
|
20
|
-
end
|
21
|
-
|
22
|
-
module NewText
|
23
|
-
def text
|
24
|
-
subject.nodes[index]
|
25
|
-
end
|
26
|
-
alias_method :object, :text
|
27
|
-
|
28
|
-
# @return [String] self description
|
29
|
-
def description
|
30
|
-
"#{super} #{subject.description} given new text '#{text}'."
|
31
|
-
end
|
32
|
-
|
33
|
-
def line_expr
|
34
|
-
subject.line < 0 ? '' : " on line #{subject.line}"
|
35
|
-
end
|
36
|
-
end # class NewContent
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/change')
|
4
|
+
|
5
|
+
module Duxml
|
6
|
+
module NewText; end
|
7
|
+
|
8
|
+
# created when object had no children or text and text has been added
|
9
|
+
class NewTextClass < ChangeClass
|
10
|
+
include NewText
|
11
|
+
|
12
|
+
# @param _subject [Duxml::Element] doc that has gained new text
|
13
|
+
# @param _index [Fixnum] index of new text node
|
14
|
+
def initialize(_subject, _str, _index)
|
15
|
+
super _subject
|
16
|
+
@index, @str = _index, _str
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :index, :str
|
20
|
+
end
|
21
|
+
|
22
|
+
module NewText
|
23
|
+
def text
|
24
|
+
subject.nodes[index]
|
25
|
+
end
|
26
|
+
alias_method :object, :text
|
27
|
+
|
28
|
+
# @return [String] self description
|
29
|
+
def description
|
30
|
+
"#{super} #{subject.description} given new text '#{text}'."
|
31
|
+
end
|
32
|
+
|
33
|
+
def line_expr
|
34
|
+
subject.line < 0 ? '' : " on line #{subject.line}"
|
35
|
+
end
|
36
|
+
end # class NewContent
|
37
37
|
end # module Duxml
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/error')
|
4
|
-
|
5
|
-
module Duxml
|
6
|
-
module QualifyError; end
|
7
|
-
|
8
|
-
# created when grammar detects error from user input
|
9
|
-
class QualifyErrorClass < ErrorClass
|
10
|
-
include QualifyError
|
11
|
-
|
12
|
-
alias_method :bad_change, :object
|
13
|
-
end
|
14
|
-
|
15
|
-
module QualifyError
|
16
|
-
|
17
|
-
def description
|
18
|
-
rule_str = rule.respond_to?(:validate) ? 'not allowed by this Grammar' : "violates #{rule.description}"
|
19
|
-
"Qualify Error #{super} #{bad_change.description} #{rule_str}."
|
20
|
-
end
|
21
|
-
end # module QualifyError
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/error')
|
4
|
+
|
5
|
+
module Duxml
|
6
|
+
module QualifyError; end
|
7
|
+
|
8
|
+
# created when grammar detects error from user input
|
9
|
+
class QualifyErrorClass < ErrorClass
|
10
|
+
include QualifyError
|
11
|
+
|
12
|
+
alias_method :bad_change, :object
|
13
|
+
end
|
14
|
+
|
15
|
+
module QualifyError
|
16
|
+
|
17
|
+
def description
|
18
|
+
rule_str = rule.respond_to?(:validate) ? 'not allowed by this Grammar' : "violates #{rule.description}"
|
19
|
+
"Qualify Error #{super} #{bad_change.description} #{rule_str}."
|
20
|
+
end
|
21
|
+
end # module QualifyError
|
22
22
|
end # module Duxml
|
@@ -1,28 +1,28 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/change')
|
4
|
-
|
5
|
-
module Duxml
|
6
|
-
module Remove; end
|
7
|
-
|
8
|
-
# created when doc loses a child
|
9
|
-
class RemoveClass < ChangeClass
|
10
|
-
include Remove
|
11
|
-
# @param _subject [Dux::Element] parent doc that lost child
|
12
|
-
# @param _child [Dux::Element] removed child; it gets added as child of this Remove object so it never actually goes away
|
13
|
-
def initialize(_subject, _child)
|
14
|
-
super(_subject)
|
15
|
-
@removed = _child
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :removed
|
19
|
-
alias_method :object, :removed
|
20
|
-
end
|
21
|
-
|
22
|
-
module Remove
|
23
|
-
# @return [String] describes removal event
|
24
|
-
def description
|
25
|
-
%(#{super} #{removed.description} removed from #{subject.description}.)
|
26
|
-
end
|
27
|
-
end # module Remove
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/change')
|
4
|
+
|
5
|
+
module Duxml
|
6
|
+
module Remove; end
|
7
|
+
|
8
|
+
# created when doc loses a child
|
9
|
+
class RemoveClass < ChangeClass
|
10
|
+
include Remove
|
11
|
+
# @param _subject [Dux::Element] parent doc that lost child
|
12
|
+
# @param _child [Dux::Element] removed child; it gets added as child of this Remove object so it never actually goes away
|
13
|
+
def initialize(_subject, _child)
|
14
|
+
super(_subject)
|
15
|
+
@removed = _child
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :removed
|
19
|
+
alias_method :object, :removed
|
20
|
+
end
|
21
|
+
|
22
|
+
module Remove
|
23
|
+
# @return [String] describes removal event
|
24
|
+
def description
|
25
|
+
%(#{super} #{removed.description} removed from #{subject.description}.)
|
26
|
+
end
|
27
|
+
end # module Remove
|
28
28
|
end # module Duxml
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../grammar/pattern')
|
4
|
-
|
5
|
-
module Duxml
|
6
|
-
# TODO NOT IMPLEMENTED YET!!!
|
7
|
-
module Undo; end
|
8
|
-
|
9
|
-
# created when a previous change is undone
|
10
|
-
class UndoClass < ChangeClass
|
11
|
-
include Undo
|
12
|
-
end
|
13
|
-
|
14
|
-
module Undo
|
15
|
-
def description
|
16
|
-
"#{super} change '#{subject.id}' undone."
|
17
|
-
end
|
18
|
-
|
19
|
-
# returns previous change instance that was undone
|
20
|
-
def undone_change
|
21
|
-
self[:change]
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../grammar/pattern')
|
4
|
+
|
5
|
+
module Duxml
|
6
|
+
# TODO NOT IMPLEMENTED YET!!!
|
7
|
+
module Undo; end
|
8
|
+
|
9
|
+
# created when a previous change is undone
|
10
|
+
class UndoClass < ChangeClass
|
11
|
+
include Undo
|
12
|
+
end
|
13
|
+
|
14
|
+
module Undo
|
15
|
+
def description
|
16
|
+
"#{super} change '#{subject.id}' undone."
|
17
|
+
end
|
18
|
+
|
19
|
+
# returns previous change instance that was undone
|
20
|
+
def undone_change
|
21
|
+
self[:change]
|
22
|
+
end
|
23
|
+
end
|
24
24
|
end # module Duxml
|
@@ -1,21 +1,21 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/error')
|
4
|
-
|
5
|
-
module Duxml
|
6
|
-
module ValidateError; end
|
7
|
-
|
8
|
-
# created when grammar detects error from file
|
9
|
-
class ValidateErrorClass < ErrorClass
|
10
|
-
include ValidateError
|
11
|
-
|
12
|
-
alias_method :bad_pattern, :object
|
13
|
-
end
|
14
|
-
|
15
|
-
module ValidateError
|
16
|
-
def description
|
17
|
-
rule_str = rule.respond_to?(:validate) ? 'not allowed by this Grammar' : "violates #{rule.description}"
|
18
|
-
"Validate Error #{super} #{bad_pattern.description} #{rule_str}."
|
19
|
-
end
|
20
|
-
end # module ValidateError
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/error')
|
4
|
+
|
5
|
+
module Duxml
|
6
|
+
module ValidateError; end
|
7
|
+
|
8
|
+
# created when grammar detects error from file
|
9
|
+
class ValidateErrorClass < ErrorClass
|
10
|
+
include ValidateError
|
11
|
+
|
12
|
+
alias_method :bad_pattern, :object
|
13
|
+
end
|
14
|
+
|
15
|
+
module ValidateError
|
16
|
+
def description
|
17
|
+
rule_str = rule.respond_to?(:validate) ? 'not allowed by this Grammar' : "violates #{rule.description}"
|
18
|
+
"Validate Error #{super} #{bad_pattern.description} #{rule_str}."
|
19
|
+
end
|
20
|
+
end # module ValidateError
|
21
21
|
end # module Duxml
|
data/lib/duxml/reportable.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
require 'observer'
|
4
|
-
|
5
|
-
module Reportable
|
6
|
-
include Observable
|
7
|
-
|
8
|
-
# @param obs [Object] observer to add to this Element as well as its NodeSet
|
9
|
-
def add_observer(obs, sym=nil)
|
10
|
-
super(obs, sym || :update)
|
11
|
-
nodes.add_observer(obs, sym || :update) if self.respond_to?(:nodes) and nodes.respond_to?(:add_observer)
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader :observer_peers
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
# all public methods that alter XML must call #report in the full scope of that public method
|
19
|
-
# in order to correctly acquire name of method that called #report
|
20
|
-
#
|
21
|
-
# @param *args [*several_variants]
|
22
|
-
def report(*args)
|
23
|
-
return nil if @observer_peers.nil?
|
24
|
-
changed
|
25
|
-
new_args = [args.first, self]
|
26
|
-
args[1..-1].each do |a| new_args << a end if args.size > 1
|
27
|
-
notify_observers(*new_args)
|
28
|
-
end
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
require 'observer'
|
4
|
+
|
5
|
+
module Reportable
|
6
|
+
include Observable
|
7
|
+
|
8
|
+
# @param obs [Object] observer to add to this Element as well as its NodeSet
|
9
|
+
def add_observer(obs, sym=nil)
|
10
|
+
super(obs, sym || :update)
|
11
|
+
nodes.add_observer(obs, sym || :update) if self.respond_to?(:nodes) and nodes.respond_to?(:add_observer)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :observer_peers
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# all public methods that alter XML must call #report in the full scope of that public method
|
19
|
+
# in order to correctly acquire name of method that called #report
|
20
|
+
#
|
21
|
+
# @param *args [*several_variants]
|
22
|
+
def report(*args)
|
23
|
+
return nil if @observer_peers.nil?
|
24
|
+
changed
|
25
|
+
new_args = [args.first, self]
|
26
|
+
args[1..-1].each do |a| new_args << a end if args.size > 1
|
27
|
+
notify_observers(*new_args)
|
28
|
+
end
|
29
29
|
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
class Fixnum
|
4
|
-
NUM_NAMES = %w(zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty thirty forty fifty sixty seventy eighty ninety)
|
5
|
-
ORDINAL_SUFFIXES = %w(th st nd rd th)
|
6
|
-
ORDINAL_NAMES = %w(zeroth first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth)
|
7
|
-
|
8
|
-
# @return [String] short string ordinal e.g. 3.ordinal =? 'third'
|
9
|
-
def ordinal
|
10
|
-
self.to_s + suffix
|
11
|
-
end
|
12
|
-
|
13
|
-
def suffix
|
14
|
-
if self%100 < 4 or self%100 > 20
|
15
|
-
ORDINAL_SUFFIXES[self%10]
|
16
|
-
else
|
17
|
-
ORDINAL_SUFFIXES.first
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# @return [String] full name of number e.g. 200058.to_word => 'two-hundred thousand and fifty-eight' for any Fixnum less than a billion
|
22
|
-
def to_word
|
23
|
-
case
|
24
|
-
when self < 21 then NUM_NAMES[self]
|
25
|
-
when self < 100
|
26
|
-
ones = self%10
|
27
|
-
ones_str = ones.zero? ? '' : "-#{ones.to_word}"
|
28
|
-
NUM_NAMES[self/10+18]+ones_str
|
29
|
-
when self < 1000
|
30
|
-
tens = self%100
|
31
|
-
"#{NUM_NAMES[self/100]} hundred #{'and '+(tens).to_word unless tens.zero?}"
|
32
|
-
when self < 1000000
|
33
|
-
remainder = self%1000 < 100 ? "and #{(self%1000).to_word}" : (self%1000).to_word
|
34
|
-
"#{(self/1000).to_word} thousand #{remainder}"
|
35
|
-
when self < 1000000000
|
36
|
-
"#{(self/1000000).to_word} million #{(self%1000000).to_word}"
|
37
|
-
else raise Exception, 'method only supports names for numbers less than 1000000000 i.e. <= 999,999,999'
|
38
|
-
end.strip.gsub(' and zero', '')
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [String] full name of ordinal number e.g. 4281.ordinal_name => 'four thousand and two-hundred eighty-first'
|
42
|
-
def ordinal_name
|
43
|
-
ones = self%10
|
44
|
-
tens = self%100
|
45
|
-
case
|
46
|
-
when tens.zero? then self.to_word+ORDINAL_SUFFIXES.first
|
47
|
-
when ones.zero? && tens > 10 then self.to_word[-3..-1] + 'tieth'
|
48
|
-
when ones.zero? && tens == 10 then self.to_word+ORDINAL_SUFFIXES.first
|
49
|
-
when tens < 13 then "#{(self-tens).to_word} and #{ORDINAL_NAMES[tens]}"
|
50
|
-
when tens < 20 && tens > 12
|
51
|
-
"#{(self-tens).to_word} and #{NUM_NAMES[tens]}#{ORDINAL_SUFFIXES.first}"
|
52
|
-
when tens-ones != 0 then "#{(self-ones).to_word}-#{ORDINAL_NAMES[ones]}"
|
53
|
-
else "#{(self-ones).to_word} and #{ORDINAL_NAMES[ones]}"
|
54
|
-
end.strip.gsub('zero and ', '').gsub('zero', '')
|
55
|
-
end
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
class Fixnum
|
4
|
+
NUM_NAMES = %w(zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty thirty forty fifty sixty seventy eighty ninety)
|
5
|
+
ORDINAL_SUFFIXES = %w(th st nd rd th)
|
6
|
+
ORDINAL_NAMES = %w(zeroth first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth)
|
7
|
+
|
8
|
+
# @return [String] short string ordinal e.g. 3.ordinal =? 'third'
|
9
|
+
def ordinal
|
10
|
+
self.to_s + suffix
|
11
|
+
end
|
12
|
+
|
13
|
+
def suffix
|
14
|
+
if self%100 < 4 or self%100 > 20
|
15
|
+
ORDINAL_SUFFIXES[self%10]
|
16
|
+
else
|
17
|
+
ORDINAL_SUFFIXES.first
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] full name of number e.g. 200058.to_word => 'two-hundred thousand and fifty-eight' for any Fixnum less than a billion
|
22
|
+
def to_word
|
23
|
+
case
|
24
|
+
when self < 21 then NUM_NAMES[self]
|
25
|
+
when self < 100
|
26
|
+
ones = self%10
|
27
|
+
ones_str = ones.zero? ? '' : "-#{ones.to_word}"
|
28
|
+
NUM_NAMES[self/10+18]+ones_str
|
29
|
+
when self < 1000
|
30
|
+
tens = self%100
|
31
|
+
"#{NUM_NAMES[self/100]} hundred #{'and '+(tens).to_word unless tens.zero?}"
|
32
|
+
when self < 1000000
|
33
|
+
remainder = self%1000 < 100 ? "and #{(self%1000).to_word}" : (self%1000).to_word
|
34
|
+
"#{(self/1000).to_word} thousand #{remainder}"
|
35
|
+
when self < 1000000000
|
36
|
+
"#{(self/1000000).to_word} million #{(self%1000000).to_word}"
|
37
|
+
else raise Exception, 'method only supports names for numbers less than 1000000000 i.e. <= 999,999,999'
|
38
|
+
end.strip.gsub(' and zero', '')
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String] full name of ordinal number e.g. 4281.ordinal_name => 'four thousand and two-hundred eighty-first'
|
42
|
+
def ordinal_name
|
43
|
+
ones = self%10
|
44
|
+
tens = self%100
|
45
|
+
case
|
46
|
+
when tens.zero? then self.to_word+ORDINAL_SUFFIXES.first
|
47
|
+
when ones.zero? && tens > 10 then self.to_word[-3..-1] + 'tieth'
|
48
|
+
when ones.zero? && tens == 10 then self.to_word+ORDINAL_SUFFIXES.first
|
49
|
+
when tens < 13 then "#{(self-tens).to_word} and #{ORDINAL_NAMES[tens]}"
|
50
|
+
when tens < 20 && tens > 12
|
51
|
+
"#{(self-tens).to_word} and #{NUM_NAMES[tens]}#{ORDINAL_SUFFIXES.first}"
|
52
|
+
when tens-ones != 0 then "#{(self-ones).to_word}-#{ORDINAL_NAMES[ones]}"
|
53
|
+
else "#{(self-ones).to_word} and #{ORDINAL_NAMES[ones]}"
|
54
|
+
end.strip.gsub('zero and ', '').gsub('zero', '')
|
55
|
+
end
|
56
56
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
-
|
3
|
-
class Module
|
4
|
-
def simple_name
|
5
|
-
self.to_s.split('::').last
|
6
|
-
end
|
7
|
-
|
8
|
-
def simple_module
|
9
|
-
a = self.to_s.split('::')
|
10
|
-
a.size > 1 ? a[-2] : 'Module'
|
11
|
-
end
|
1
|
+
# Copyright (c) 2016 Freescale Semiconductor Inc.
|
2
|
+
|
3
|
+
class Module
|
4
|
+
def simple_name
|
5
|
+
self.to_s.split('::').last
|
6
|
+
end
|
7
|
+
|
8
|
+
def simple_module
|
9
|
+
a = self.to_s.split('::')
|
10
|
+
a.size > 1 ? a[-2] : 'Module'
|
11
|
+
end
|
12
12
|
end
|