Class: DiffTools::Chunk

Inherits:
Object show all
Defined in:
lib/diff_tools.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(anObject) ⇒ Chunk

Returns a new instance of Chunk.



74
75
76
77
78
79
80
81
82
83
# File 'lib/diff_tools.rb', line 74

def initialize ( anObject )
  case anObject
  when String
    @path = anObject[/\AIndex: (.+)$/, 1]
    raise ArgumentError, "The path cannot be empty (#{anObject})" if @path.nil? or @path.empty?
    @contents = anObject
  else
    raise TypeError, "Unexpected type #{anObject.class}"
  end
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



72
73
74
# File 'lib/diff_tools.rb', line 72

def contents
  @contents
end

#pathObject (readonly)

Returns the value of attribute path.



72
73
74
# File 'lib/diff_tools.rb', line 72

def path
  @path
end

Instance Method Details

#inspectObject



89
90
91
# File 'lib/diff_tools.rb', line 89

def inspect
  "#<#{self.class}: Index: #@path>"
end

#to_sObject



85
86
87
# File 'lib/diff_tools.rb', line 85

def to_s
  @contents
end