Class: Serverspec::Type::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/serverspec/type/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Base

Returns a new instance of Base


6
7
8
9
# File 'lib/serverspec/type/base.rb', line 6

def initialize(name=nil)
  @name   = name
  @runner = Specinfra::Runner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


4
5
6
# File 'lib/serverspec/type/base.rb', line 4

def name
  @name
end

Instance Method Details

#inspectObject


18
19
20
21
22
23
24
# File 'lib/serverspec/type/base.rb', line 18

def inspect
  if defined?(PowerAssert)
    @inspection
  else
    to_s
  end
end

#to_aryObject


26
27
28
# File 'lib/serverspec/type/base.rb', line 26

def to_ary
  to_s.split(" ")
end

#to_sObject


11
12
13
14
15
16
# File 'lib/serverspec/type/base.rb', line 11

def to_s
  type = self.class.name.split(':')[-1]
  type.gsub!(/([a-z\d])([A-Z])/, '\1 \2')
  type.capitalize!
  %Q!#{type} "#{@name}"!
end