Class: XDry::SynthesizeItem
- Inherits:
-
Object
- Object
- XDry::SynthesizeItem
- Defined in:
- lib/xdry/parsing/nodes.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#property_name ⇒ Object
readonly
Returns the value of attribute property_name.
Class Method Summary collapse
Instance Method Summary collapse
- #has_field_name? ⇒ Boolean
-
#initialize(property_name, field_name = nil) ⇒ SynthesizeItem
constructor
A new instance of SynthesizeItem.
- #to_s ⇒ Object
Constructor Details
#initialize(property_name, field_name = nil) ⇒ SynthesizeItem
Returns a new instance of SynthesizeItem.
152 153 154 |
# File 'lib/xdry/parsing/nodes.rb', line 152 def initialize property_name, field_name = nil @property_name, @field_name = property_name, field_name end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
150 151 152 |
# File 'lib/xdry/parsing/nodes.rb', line 150 def field_name @field_name end |
#property_name ⇒ Object (readonly)
Returns the value of attribute property_name.
150 151 152 |
# File 'lib/xdry/parsing/nodes.rb', line 150 def property_name @property_name end |
Class Method Details
.parse(string) ⇒ Object
168 169 170 171 172 173 |
# File 'lib/xdry/parsing/nodes.rb', line 168 def self.parse string case string when /^(\w+)$/ then SynthesizeItem.new($1, nil) when /^(\w+)\s*=\s*(\w+)$/ then SynthesizeItem.new($1, $2) end end |
Instance Method Details
#has_field_name? ⇒ Boolean
156 157 158 |
# File 'lib/xdry/parsing/nodes.rb', line 156 def has_field_name? not @field_name.nil? end |
#to_s ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/xdry/parsing/nodes.rb', line 160 def to_s if has_field_name? "#{property_name}=#{field_name}" else "#{property_name}" end end |