Class: AutoC::Value
- Inherits:
-
Object
- Object
- AutoC::Value
- Defined in:
- lib/autoc/function.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #call(value) ⇒ Object
- #constant? ⇒ Boolean
-
#initialize(type, constant: false, reference: false) ⇒ Value
constructor
A new instance of Value.
- #reference? ⇒ Boolean
- #signature ⇒ Object
- #to_s ⇒ Object
- #to_type ⇒ Object
- #to_value ⇒ Object
Constructor Details
#initialize(type, constant: false, reference: false) ⇒ Value
Returns a new instance of Value.
25 26 27 28 29 |
# File 'lib/autoc/function.rb', line 25 def initialize(type, constant: false, reference: false) @type = type @constant = constant @reference = reference end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/autoc/function.rb', line 15 def type @type end |
Instance Method Details
#call(value) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/autoc/function.rb', line 38 def call(value) value = value.to_s if reference? # Manually collapse references &*xyz -> xyz for the sake of source code readability value[0] =='*' ? value[1..-1] : "&#{value}" else value end end |
#constant? ⇒ Boolean
21 |
# File 'lib/autoc/function.rb', line 21 def constant? = @constant == true |
#reference? ⇒ Boolean
23 |
# File 'lib/autoc/function.rb', line 23 def reference? = @reference == true |
#signature ⇒ Object
33 34 35 36 |
# File 'lib/autoc/function.rb', line 33 def signature _ = reference? ? "#{type.signature}*" : type.signature constant? ? "const #{_}" : _ end |
#to_s ⇒ Object
31 |
# File 'lib/autoc/function.rb', line 31 def to_s = signature |
#to_type ⇒ Object
17 |
# File 'lib/autoc/function.rb', line 17 def to_type = type |
#to_value ⇒ Object
19 |
# File 'lib/autoc/function.rb', line 19 def to_value = self |