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.
26 27 28 29 30 |
# File 'lib/autoc/function.rb', line 26 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.
16 17 18 |
# File 'lib/autoc/function.rb', line 16 def type @type end |
Instance Method Details
#call(value) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/autoc/function.rb', line 39 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
22 |
# File 'lib/autoc/function.rb', line 22 def constant? = @constant == true |
#reference? ⇒ Boolean
24 |
# File 'lib/autoc/function.rb', line 24 def reference? = @reference == true |
#signature ⇒ Object
34 35 36 37 |
# File 'lib/autoc/function.rb', line 34 def signature _ = reference? ? "#{type.signature}*" : type.signature constant? ? "const #{_}" : _ end |
#to_s ⇒ Object
32 |
# File 'lib/autoc/function.rb', line 32 def to_s = signature |
#to_type ⇒ Object
18 |
# File 'lib/autoc/function.rb', line 18 def to_type = type |
#to_value ⇒ Object
20 |
# File 'lib/autoc/function.rb', line 20 def to_value = self |