Class: Fabulator::TagLib::TypeConversion
- Inherits:
-
Object
- Object
- Fabulator::TagLib::TypeConversion
- Defined in:
- lib/fabulator/tag_lib/type.rb
Instance Method Summary collapse
- #convert(v) ⇒ Object
-
#converting(&block) ⇒ Object
def guard(&block) if !block.nil? @guard = block end end.
-
#initialize(t) ⇒ TypeConversion
constructor
A new instance of TypeConversion.
- #vtype ⇒ Object
- #weight(w = nil) ⇒ Object
Constructor Details
#initialize(t) ⇒ TypeConversion
Returns a new instance of TypeConversion.
142 143 144 145 146 |
# File 'lib/fabulator/tag_lib/type.rb', line 142 def initialize(t) @type = t @weight = 0.0 # @guard = nil end |
Instance Method Details
#convert(v) ⇒ Object
167 168 169 170 |
# File 'lib/fabulator/tag_lib/type.rb', line 167 def convert(v) return v.root.anon_node(nil) if @conversion.nil? @conversion.call(v) end |
#converting(&block) ⇒ Object
def guard(&block)
if !block.nil?
@guard = block
end
end
163 164 165 |
# File 'lib/fabulator/tag_lib/type.rb', line 163 def converting(&block) @conversion = block end |
#vtype ⇒ Object
148 149 150 |
# File 'lib/fabulator/tag_lib/type.rb', line 148 def vtype @type end |
#weight(w = nil) ⇒ Object
152 153 154 155 |
# File 'lib/fabulator/tag_lib/type.rb', line 152 def weight(w = nil) @weight = w unless w.nil? @weight end |