Class: XDry::NPropertyDef
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(name, type) ⇒ NPropertyDef
constructor
A new instance of NPropertyDef.
- #outlet? ⇒ Boolean
- #to_s ⇒ Object
- #to_source ⇒ Object
Methods inherited from Node
#method_missing, #tagged_with?, #tags, #tags=, #tags_comment
Constructor Details
#initialize(name, type) ⇒ NPropertyDef
Returns a new instance of NPropertyDef.
73 74 75 76 77 |
# File 'lib/xdry/parsing/nodes.rb', line 73 def initialize name, type super() raise StandardError, "type cannot be nil for prop #{name}" if type.nil? @name, @type = name, type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XDry::Node
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
71 72 73 |
# File 'lib/xdry/parsing/nodes.rb', line 71 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
71 72 73 |
# File 'lib/xdry/parsing/nodes.rb', line 71 def type @type end |
Instance Method Details
#outlet? ⇒ Boolean
79 80 81 |
# File 'lib/xdry/parsing/nodes.rb', line 79 def outlet? tagged_with? 'outlet' end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/xdry/parsing/nodes.rb', line 83 def to_s "#{if outlet? then 'IBOutlet ' else '' end}#{@type} #{@name}" end |
#to_source ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/xdry/parsing/nodes.rb', line 87 def to_source retainment = case @type.default_property_retainment_policy when '' then '' else ', ' + @type.default_property_retainment_policy end iboutlet = if outlet? then "IBOutlet " else '' end "@property(nonatomic#{retainment}) #{iboutlet}#{@type.to_source_with_space}#{@name};" end |