Class: Gem::Comparator::Report::Entry

Inherits:
Object
  • Object
show all
Includes:
UserInteraction
Defined in:
lib/rubygems/comparator/report/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = '', indent = '') ⇒ Entry

Returns a new instance of Entry.



8
9
10
11
# File 'lib/rubygems/comparator/report/entry.rb', line 8

def initialize(data = '', indent = '')
  @data = data
  @indent = indent
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/rubygems/comparator/report/entry.rb', line 6

def data
  @data
end

#indentObject

Returns the value of attribute indent.



6
7
8
# File 'lib/rubygems/comparator/report/entry.rb', line 6

def indent
  @indent
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/rubygems/comparator/report/entry.rb', line 18

def empty?
  case @data
  when String, Array
    @data.empty?
  end
end


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubygems/comparator/report/entry.rb', line 25

def print
  printed = case @data
            when String
              "#{@indent}#{@data}"
            when Array
              @indent + @data.join("\n#{@indent}")
            else
              "#{@indent}#{@data}"
            end
  say printed
end

#set_indent!(indent) ⇒ Object



13
14
15
16
# File 'lib/rubygems/comparator/report/entry.rb', line 13

def set_indent!(indent)
  @indent = indent
  self
end