Class: Tairb::Configuration
- Inherits:
-
Object
- Object
- Tairb::Configuration
- Defined in:
- lib/tairb/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ bytes: 10000 }
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#script ⇒ Object
Returns the value of attribute script.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #default_script ⇒ Object
- #default_serialize ⇒ Object
-
#initialize(context, config = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #tailf_method ⇒ Object
Constructor Details
#initialize(context, config = {}) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 |
# File 'lib/tairb/configuration.rb', line 10 def initialize context, config={} @context = context config = DEFAULTS.merge config %i[ type bytes filter script ].each do |key| self.send "#{key}=", config[key] if config.key? key end end |
Instance Attribute Details
#bytes ⇒ Object
Returns the value of attribute bytes.
7 8 9 |
# File 'lib/tairb/configuration.rb', line 7 def bytes @bytes end |
#filter ⇒ Object
Returns the value of attribute filter.
8 9 10 |
# File 'lib/tairb/configuration.rb', line 8 def filter @filter end |
#script ⇒ Object
Returns the value of attribute script.
7 8 9 |
# File 'lib/tairb/configuration.rb', line 7 def script @script end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/tairb/configuration.rb', line 7 def type @type end |
Instance Method Details
#default_script ⇒ Object
30 31 32 33 |
# File 'lib/tairb/configuration.rb', line 30 def default_script serialize = @context.method default_serialize proc { |dat| puts serialize.call(dat) } end |
#default_serialize ⇒ Object
34 35 36 37 38 39 |
# File 'lib/tairb/configuration.rb', line 34 def default_serialize case self.type when :tsv then :to_tsv else :to_s end end |
#tailf_method ⇒ Object
23 24 25 26 27 28 |
# File 'lib/tairb/configuration.rb', line 23 def tailf_method case self.type when :tsv then :tailf_tsv else :tailf end end |