Class: Souffle::Node::RunListItem

Inherits:
Object
  • Object
show all
Defined in:
lib/souffle/node/runlist_item.rb

Overview

A single runlist item, most be parsed and either a recipe or role.

Instance Method Summary collapse

Constructor Details

#initialize(item = nil) ⇒ RunListItem

Creates a new runlist item from a string.

the runlist item or type isn’t a proper chef role or recipe.

Parameters:

  • item (String) (defaults to: nil)

    The runlist string to turn into an object.

Raises:

  • (InvalidRunlistName, InvalidRunlistType)

    Raises exceptions when



11
12
13
14
# File 'lib/souffle/node/runlist_item.rb', line 11

def initialize(item=nil)
  @original_item = item
  @item = Souffle::Node::RunListParser.parse(item)
end

Instance Method Details

#==(runlist_item) ⇒ Boolean

Overriding the default equality comparator to use string representation.

Parameters:

Returns:

  • (Boolean)

    Whether or not the objects are equal.



40
41
42
# File 'lib/souffle/node/runlist_item.rb', line 40

def ==(runlist_item)
  self.to_s == runlist_item.to_s
end

#eql?(runlist_item) ⇒ Boolean

Overriding the default equality comparator to use string representation.

Parameters:

Returns:

  • (Boolean)

    Whether or not the objects are equal.



49
50
51
# File 'lib/souffle/node/runlist_item.rb', line 49

def eql?(runlist_item)
  self.to_s == runlist_item.to_s
end

#nameString

Returns the name of the runlist item.

Returns:

  • (String)

    The name of the runlist item.



19
20
21
# File 'lib/souffle/node/runlist_item.rb', line 19

def name
  @item["name"]
end

#to_sObject

Returns the RunListItem as it’s original string.



31
32
33
# File 'lib/souffle/node/runlist_item.rb', line 31

def to_s
  @original_item
end

#typeString

Returns the type of the runlist item.

Returns:

  • (String)

    The type of the runlist item.



26
27
28
# File 'lib/souffle/node/runlist_item.rb', line 26

def type
  @item["type"]
end