Class: LogStash::Setting::Bytes
- Inherits:
- 
      Coercible
      
        - Object
- LogStash::Setting
- Coercible
- LogStash::Setting::Bytes
 
- Defined in:
- lib/logstash/settings.rb
Instance Attribute Summary
Attributes inherited from LogStash::Setting
Instance Method Summary collapse
- #coerce(value) ⇒ Object
- 
  
    
      #initialize(name, default = nil, strict = true)  ⇒ Bytes 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Bytes. 
- #valid?(value) ⇒ Boolean
- #validate(value) ⇒ Object
Methods inherited from Coercible
Methods inherited from LogStash::Setting
#==, #reset, #set, #set?, #strict?, #to_hash, #validate_value, #value
Methods included from Util::Loggable
included, #logger, #slow_logger
Constructor Details
#initialize(name, default = nil, strict = true) ⇒ Bytes
Returns a new instance of Bytes.
| 479 480 481 | # File 'lib/logstash/settings.rb', line 479 def initialize(name, default=nil, strict=true) super(name, ::Fixnum, default, strict=true) { |value| valid?(value) } end | 
Instance Method Details
#coerce(value) ⇒ Object
| 487 488 489 490 491 492 493 494 495 496 | # File 'lib/logstash/settings.rb', line 487 def coerce(value) case value when ::Numeric value when ::String LogStash::Util::ByteValue.parse(value) else raise ArgumentError.new("Could not coerce '#{value}' into a bytes value") end end | 
#valid?(value) ⇒ Boolean
| 483 484 485 | # File 'lib/logstash/settings.rb', line 483 def valid?(value) value.is_a?(Fixnum) && value >= 0 end | 
#validate(value) ⇒ Object
| 498 499 500 501 502 | # File 'lib/logstash/settings.rb', line 498 def validate(value) unless valid?(value) raise ArgumentError.new("Invalid byte value \"#{value}\".") end end |