Class: Icss::Type
Overview
Describes an avro type
A Schema is represented in JSON by one of:
-
A JSON string, naming a defined type.
-
A JSON object, of the form:
{"type": "typeName" ...attributes...}
where typeName is either a primitive or derived type name, as defined in the Icss::Type class
-
A JSON array, representing a union of embedded types.
Direct Known Subclasses
Constant Summary collapse
- PRIMITIVE_TYPES =
{}
Class Method Summary collapse
- .find(type_name) ⇒ Object
-
.pig_name ⇒ Object
Schema Translation.
- .primitive?(name) ⇒ Boolean
Instance Method Summary collapse
- #primitive? ⇒ Boolean
- #title ⇒ Object
-
#to_hash ⇒ Object
Conversion.
-
#to_json ⇒ Object
This will cause funny errors when it is an element of something that’s to_json’ed.
Class Method Details
.find(type_name) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/icss/type.rb', line 35 def self.find type_name if type_name.to_s.include?('.') warn "crap. can't properly do namespaced types yet." type_name = type_name.to_s.gsub(/(.*)\./, "") end Icss::Type::VALID_TYPES[type_name.to_sym] || Icss::Type::DERIVED_TYPES[type_name.to_sym] end |
.pig_name ⇒ Object
Schema Translation
57 58 59 |
# File 'lib/icss/type.rb', line 57 def self.pig_name "undefined_#{self.to_s.underscore}" end |
.primitive?(name) ⇒ Boolean
43 44 45 |
# File 'lib/icss/type.rb', line 43 def self.primitive? name PRIMITIVE_TYPES.include?(name.to_sym) end |
Instance Method Details
#primitive? ⇒ Boolean
46 47 48 |
# File 'lib/icss/type.rb', line 46 def primitive? false end |
#title ⇒ Object
50 51 52 |
# File 'lib/icss/type.rb', line 50 def title self.name end |
#to_hash ⇒ Object
Conversion
64 65 66 |
# File 'lib/icss/type.rb', line 64 def to_hash() {:name => name, :doc => doc }.reject{|k,v| v.nil? } end |
#to_json ⇒ Object
This will cause funny errors when it is an element of something that’s to_json’ed
68 |
# File 'lib/icss/type.rb', line 68 def to_json() to_hash.to_json ; end |