Class: HTOTConv::Outline::Item

Inherits:
Struct
  • Object
show all
Defined in:
lib/htot_conv/outline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



77
78
79
# File 'lib/htot_conv/outline.rb', line 77

def key
  @key
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



77
78
79
# File 'lib/htot_conv/outline.rb', line 77

def level
  @level
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



77
78
79
# File 'lib/htot_conv/outline.rb', line 77

def value
  @value
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


85
86
87
88
89
90
91
92
# File 'lib/htot_conv/outline.rb', line 85

def valid?
  begin
    validate
    true
  rescue ValidationError
    false
  end
end

#validateObject

Raises:



78
79
80
81
82
83
# File 'lib/htot_conv/outline.rb', line 78

def validate
  raise ValidationError, "item level for item \"#{key}\" must be an integer" unless self.level.kind_of?(Numeric)
  raise ValidationError, "item level for item \"#{key}\" must be positive" unless self.level > 0
  raise ValidationError, "item level for item \"#{key}\" must be an integer" unless (self.level.to_i == self.level)
  raise ValidationError, "value for item \"#{key}\" must be an array" unless self.value.kind_of?(Array)
end