Class: Fabulator::TagLib::Type
- Inherits:
-
Object
- Object
- Fabulator::TagLib::Type
- Defined in:
- lib/fabulator/tag_lib/type.rb
Instance Method Summary collapse
- #build_conversion_to(to) ⇒ Object
- #coming_from(t, &block) ⇒ Object
- #get_method(nom) ⇒ Object
- #going_to(t, &block) ⇒ Object
- #incoming_conversions ⇒ Object
-
#initialize(t) ⇒ Type
constructor
A new instance of Type.
- #method(nom, &block) ⇒ Object
- #outgoing_conversions ⇒ Object
- #unify_with_type(t) ⇒ Object
- #vtype ⇒ Object
Constructor Details
#initialize(t) ⇒ Type
Returns a new instance of Type.
4 5 6 7 8 9 |
# File 'lib/fabulator/tag_lib/type.rb', line 4 def initialize(t) @type = t @goings = { } @comings = { } @methods = { } end |
Instance Method Details
#build_conversion_to(to) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fabulator/tag_lib/type.rb', line 47 def build_conversion_to(to) return [] if to.nil? || self == to ut = self._unify_types(to, true) return [] if ut.nil? || ut[:t].nil? || ut[:t].vtype.join('') != to.join('') return ut[:convert] end |
#coming_from(t, &block) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/fabulator/tag_lib/type.rb', line 23 def coming_from(t, &block) return unless block @comings[t.join('')] ||= [ ] obj = TypeConversion.new(t) obj.instance_eval &block @comings[t.join('')] = obj end |
#get_method(nom) ⇒ Object
43 44 45 |
# File 'lib/fabulator/tag_lib/type.rb', line 43 def get_method(nom) @methods[nom] end |
#going_to(t, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fabulator/tag_lib/type.rb', line 15 def going_to(t, &block) return unless block @goings[t.join('')] ||= [ ] obj = TypeConversion.new(t) obj.instance_eval &block @goings[t.join('')] = obj end |
#incoming_conversions ⇒ Object
35 36 37 |
# File 'lib/fabulator/tag_lib/type.rb', line 35 def incoming_conversions @comings end |
#method(nom, &block) ⇒ Object
39 40 41 |
# File 'lib/fabulator/tag_lib/type.rb', line 39 def method(nom, &block) @methods[@type[0] + nom.to_s] = block end |
#outgoing_conversions ⇒ Object
31 32 33 |
# File 'lib/fabulator/tag_lib/type.rb', line 31 def outgoing_conversions @goings end |
#unify_with_type(t) ⇒ Object
54 55 56 |
# File 'lib/fabulator/tag_lib/type.rb', line 54 def unify_with_type(t) self._unify_types(t) end |
#vtype ⇒ Object
11 12 13 |
# File 'lib/fabulator/tag_lib/type.rb', line 11 def vtype @type end |