Class: Srx::Data::LanguageRule::Rule
- Inherits:
-
XmlWrapper
- Object
- XmlWrapper
- Srx::Data::LanguageRule::Rule
- Defined in:
- lib/srx/data.rb
Overview
SRX <rule> element
Constant Summary
Constants inherited from XmlWrapper
Instance Attribute Summary collapse
- #after_break ⇒ Regexp? readonly
- #before_break ⇒ Regexp? readonly
Instance Method Summary collapse
- #break? ⇒ Boolean
-
#initialize(xml) ⇒ Rule
constructor
A new instance of Rule.
- #inspect ⇒ Object
Constructor Details
#initialize(xml) ⇒ Rule
Returns a new instance of Rule.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/srx/data.rb', line 127 def initialize(xml) super(xml) # Eagerly load everything for this class because before_break and # after_break can be legitimately nil, so lazy loading gets ugly. @break = @xml['break'].then { |brk| brk.nil? || brk == 'yes' } @before_break = xpath(:beforebreak).first&.text.then do |pattern| IcuRegex.compile(pattern) if pattern end @after_break = xpath(:afterbreak).first&.text.then do |pattern| IcuRegex.compile(pattern) if pattern end end |
Instance Attribute Details
#after_break ⇒ Regexp? (readonly)
125 126 127 |
# File 'lib/srx/data.rb', line 125 def after_break @after_break end |
#before_break ⇒ Regexp? (readonly)
122 123 124 |
# File 'lib/srx/data.rb', line 122 def before_break @before_break end |
Instance Method Details
#break? ⇒ Boolean
144 145 146 |
# File 'lib/srx/data.rb', line 144 def break? @break end |
#inspect ⇒ Object
148 149 150 |
# File 'lib/srx/data.rb', line 148 def inspect "Rule[break=#{break?},before=#{before_break},after=#{after_break}]" end |