Class: Nginxtra::Config::Indentation

Inherits:
Object
  • Object
show all
Defined in:
lib/nginxtra/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Indentation

Returns a new instance of Indentation.



639
640
641
642
# File 'lib/nginxtra/config.rb', line 639

def initialize(options = {})
  @value = 0
  @options = options
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



637
638
639
# File 'lib/nginxtra/config.rb', line 637

def value
  @value
end

Instance Method Details

#+(amount) ⇒ Object



656
657
658
659
660
# File 'lib/nginxtra/config.rb', line 656

def +(amount)
  @value += amount
  raise Nginxtra::Error::ConvertFailed.new("Missing block end!") if @value < 0
  @value
end

#-(amount) ⇒ Object



652
653
654
# File 'lib/nginxtra/config.rb', line 652

def -(amount)
  self + (-amount)
end

#done?Boolean

Returns:

  • (Boolean)


648
649
650
# File 'lib/nginxtra/config.rb', line 648

def done?
  @value == 0
end

#indent_sizeObject



644
645
646
# File 'lib/nginxtra/config.rb', line 644

def indent_size
  @options[:indent_size] || 2
end

#to_sObject



662
663
664
# File 'lib/nginxtra/config.rb', line 662

def to_s
  " " * indent_size * @value
end