Class: RecordSchema
- Inherits:
-
Object
- Object
- RecordSchema
- Defined in:
- lib/fluent/plugin/datahub/datahub-record-schema.rb
Instance Method Summary collapse
- #add_field(field) ⇒ Object
- #get_encoding ⇒ Object
- #get_field(name) ⇒ Object
- #get_fields ⇒ Object
-
#initialize ⇒ RecordSchema
constructor
A new instance of RecordSchema.
- #setEncoding(encoding) ⇒ Object
- #to_json(*a) ⇒ Object
Constructor Details
#initialize ⇒ RecordSchema
Returns a new instance of RecordSchema.
28 29 30 31 32 33 34 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 28 def initialize() @fields = [] @encoding = nil @fields_map = {} end |
Instance Method Details
#add_field(field) ⇒ Object
48 49 50 51 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 48 def add_field(field) @fields.push(field) @fields_map[field.get_name] = field end |
#get_encoding ⇒ Object
44 45 46 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 44 def get_encoding return @encoding end |
#get_field(name) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 53 def get_field(name) # @fields.each do |field| # if field.get_name == name # return field # end # end # return nil return @fields_map[name] end |
#get_fields ⇒ Object
63 64 65 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 63 def get_fields() return @fields end |
#setEncoding(encoding) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 36 def setEncoding(encoding) if ["US-ASCII", "ASCII-8BIT", "UTF-8", "ISO-8859-1", "Shift_JIS", "EUC-JP", "Windows-31J", "BINARY", "CP932", "eucJP"].include?(encoding) @encoding = encoding else raise "Unsupported encoding type [" + encoding.to_s + "]." end end |
#to_json(*a) ⇒ Object
67 68 69 70 71 |
# File 'lib/fluent/plugin/datahub/datahub-record-schema.rb', line 67 def to_json(*a) tuple = {} tuple["fields"] = @fields tuple.to_json(*a) end |