Class: Bricolage::StringResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/bricolage/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#each_line

Constructor Details

#initialize(content, name = '(string)') ⇒ StringResource

Returns a new instance of StringResource.



46
47
48
49
# File 'lib/bricolage/resource.rb', line 46

def initialize(content, name = '(string)')
  @content = content
  @name = name
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



51
52
53
# File 'lib/bricolage/resource.rb', line 51

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



52
53
54
# File 'lib/bricolage/resource.rb', line 52

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



58
59
60
61
# File 'lib/bricolage/resource.rb', line 58

def ==(other)
  return false unless other.kind_of?(StringResource)
  @name == other.name and @content == other.content
end

#hashObject



63
64
65
# File 'lib/bricolage/resource.rb', line 63

def hash
  @name.hash ^ @content.hash
end

#inspectObject



54
55
56
# File 'lib/bricolage/resource.rb', line 54

def inspect
  "\#<#{self.class} #{(@content.size > 20 ? @content[0, 20] : @content).inspect}>"
end