Class: CHBuild::Config::Version

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

Overview

Version section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

version is required so no default value



9
10
11
12
# File 'lib/chbuild/config/version.rb', line 9

def initialize(version)
  validate!(version)
  @yaml_version = version
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



27
28
29
# File 'lib/chbuild/config/version.rb', line 27

def errors
  @errors
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/chbuild/config/version.rb', line 14

def inspect
  @yaml_version.to_s
end

#nameObject



29
30
31
# File 'lib/chbuild/config/version.rb', line 29

def name
  "Section 'version'"
end

#validate!(version) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/chbuild/config/version.rb', line 18

def validate!(version)
  @errors = []
  if version.nil?
    @errors << 'Required'
    return
  end
  @errors << "Unknown value: '#{version}'" unless ALLOWED_VALUES.include? version
end