Class: Spout::Helpers::Semantic

Inherits:
Object
  • Object
show all
Defined in:
lib/spout/helpers/semantic.rb

Overview

Finds compatible versions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, version_strings) ⇒ Semantic

Returns a new instance of Semantic.



41
42
43
44
# File 'lib/spout/helpers/semantic.rb', line 41

def initialize(version, version_strings)
  @data_dictionary_version = Spout::Helpers::Version.new(version)
  @versions = version_strings.collect { |vs| Spout::Helpers::Version.new(vs) }.sort_by(&:rank)
end

Instance Attribute Details

#data_dictionary_versionObject

Returns the value of attribute data_dictionary_version.



39
40
41
# File 'lib/spout/helpers/semantic.rb', line 39

def data_dictionary_version
  @data_dictionary_version
end

Instance Method Details

#buildObject



74
75
76
# File 'lib/spout/helpers/semantic.rb', line 74

def build
  @data_dictionary_version.build
end

#majorObject



62
63
64
# File 'lib/spout/helpers/semantic.rb', line 62

def major
  @data_dictionary_version.major
end

#minorObject



66
67
68
# File 'lib/spout/helpers/semantic.rb', line 66

def minor
  @data_dictionary_version.minor
end

#selected_folderObject



50
51
52
53
54
55
56
# File 'lib/spout/helpers/semantic.rb', line 50

def selected_folder
  if valid_versions.size == 0 || valid_versions.collect(&:string).include?(version)
    version
  else
    valid_versions.collect(&:string).last
  end
end

#tinyObject



70
71
72
# File 'lib/spout/helpers/semantic.rb', line 70

def tiny
  @data_dictionary_version.tiny
end

#valid_versionsObject



46
47
48
# File 'lib/spout/helpers/semantic.rb', line 46

def valid_versions
  @versions.select { |v| v.major == major && v.minor == minor }
end

#versionObject



58
59
60
# File 'lib/spout/helpers/semantic.rb', line 58

def version
  @data_dictionary_version.string
end