Class: Bricolage::StringResource
- Defined in:
- lib/bricolage/resource.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(content, name = '(string)') ⇒ StringResource
constructor
A new instance of StringResource.
- #inspect ⇒ Object
Methods inherited from Resource
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
51 52 53 |
# File 'lib/bricolage/resource.rb', line 51 def content @content end |
#name ⇒ Object (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 |
#hash ⇒ Object
63 64 65 |
# File 'lib/bricolage/resource.rb', line 63 def hash @name.hash ^ @content.hash end |
#inspect ⇒ Object
54 55 56 |
# File 'lib/bricolage/resource.rb', line 54 def inspect "\#<#{self.class} #{(@content.size > 20 ? @content[0, 20] : @content).inspect}>" end |