Class: Craig::Listing::Base
- Inherits:
-
Object
- Object
- Craig::Listing::Base
- Includes:
- Node::HasImage, Node::HasMap, Node::Id, Node::Location, Node::PostedAt, Node::Title, Node::Url
- Defined in:
- lib/craig/listing.rb
Instance Attribute Summary collapse
-
#dom ⇒ Object
readonly
Returns the value of attribute dom.
Instance Method Summary collapse
-
#initialize(dom) ⇒ Base
constructor
A new instance of Base.
-
#listing_methods ⇒ Array
The available methods for this listing.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods included from Node::HasMap
Methods included from Node::HasImage
Methods included from Node::Id
Methods included from Node::Url
Methods included from Node::Location
Methods included from Node::PostedAt
Methods included from Node::Title
Constructor Details
#initialize(dom) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/craig/listing.rb', line 6 def initialize(dom) @dom = dom end |
Instance Attribute Details
#dom ⇒ Object (readonly)
Returns the value of attribute dom.
4 5 6 |
# File 'lib/craig/listing.rb', line 4 def dom @dom end |
Instance Method Details
#listing_methods ⇒ Array
The available methods for this listing.
23 24 25 26 |
# File 'lib/craig/listing.rb', line 23 def listing_methods (self.class.instance_methods & Node.all_methods) .sort.reverse! end |
#to_hash ⇒ Object
16 17 18 |
# File 'lib/craig/listing.rb', line 16 def to_hash Hash[listing_methods.map {|m| [m, send(m)] }] end |
#to_s ⇒ Object
10 11 12 13 14 |
# File 'lib/craig/listing.rb', line 10 def to_s "{\n " << to_hash.map do |key, value| ":#{key} => #{value.inspect}" end.join("\n ") << "\n}" end |