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.



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

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#+(amount) ⇒ Object



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

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

#-(amount) ⇒ Object



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

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

#done?Boolean

Returns:

  • (Boolean)


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

def done?
  @value == 0
end

#indent_sizeObject



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

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

#to_sObject



666
667
668
# File 'lib/nginxtra/config.rb', line 666

def to_s
  " " * indent_size * @value
end