Class: ChefCLI::Policyfile::SolutionDependencies::Cookbook

Inherits:
Struct
  • Object
show all
Defined in:
lib/chef-cli/policyfile/solution_dependencies.rb,
lib/chef-cli/policyfile/solution_dependencies.rb

Constant Summary collapse

VALID_STRING_FORMAT =
/\A[^\s]+ \([^\s]+\)\Z/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



27
28
29
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 27

def name
  @name
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



27
28
29
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 27

def version
  @version
end

Class Method Details

.parse(str) ⇒ Object



37
38
39
40
41
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 37

def self.parse(str)
  name, version_w_parens = str.split(" ")
  version = version_w_parens[/\(([^)]+)\)/, 1]
  new(name, version)
end

.valid_str?(str) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 33

def self.valid_str?(str)
  !!(str =~ VALID_STRING_FORMAT)
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 47

def eql?(other)
  other.is_a?(self.class) &&
    other.name == name &&
    other.version == version
end

#hashObject



53
54
55
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 53

def hash
  [name, version].hash
end

#to_sObject



43
44
45
# File 'lib/chef-cli/policyfile/solution_dependencies.rb', line 43

def to_s
  "#{name} (#{version})"
end