Class: XDry::NSynthesize

Inherits:
Node
  • Object
show all
Defined in:
lib/xdry/parsing/nodes.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#indent, #pos

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#method_missing, #tagged_with?, #tags, #tags=, #tags_comment

Constructor Details

#initialize(items) ⇒ NSynthesize

Returns a new instance of NSynthesize.



181
182
183
# File 'lib/xdry/parsing/nodes.rb', line 181

def initialize items
  @items = items
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class XDry::Node

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



179
180
181
# File 'lib/xdry/parsing/nodes.rb', line 179

def items
  @items
end

Class Method Details

.parse(string) ⇒ Object



193
194
195
196
197
# File 'lib/xdry/parsing/nodes.rb', line 193

def self.parse string
  if string =~ /^@synthesize\s+(.*);$/
    NSynthesize.new($1.strip.split(/\s+,\s+/).collect { |s| SynthesizeItem.parse(s) }.compact)
  end
end

Instance Method Details

#item_for_property_named(property_name) ⇒ Object



185
186
187
# File 'lib/xdry/parsing/nodes.rb', line 185

def item_for_property_named property_name
  @items.find { |item| item.property_name == property_name }
end

#to_sObject



189
190
191
# File 'lib/xdry/parsing/nodes.rb', line 189

def to_s
  "@synthesize " + @items.join(", ") + ";"
end