Class: Retort::Rtorrent
- Inherits:
-
Object
- Object
- Retort::Rtorrent
- Defined in:
- lib/retort/rtorrent.rb
Constant Summary collapse
- TYPES =
{ time: 'to_time', date: 'to_date', size: 'to_xb' }
Class Attribute Summary collapse
-
.attr_mappings ⇒ Object
Returns the value of attribute attr_mappings.
-
.attributes ⇒ Object
Returns the value of attribute attributes.
-
.attributes_raw ⇒ Object
Returns the value of attribute attributes_raw.
-
.prefix ⇒ Object
Returns the value of attribute prefix.
Class Method Summary collapse
- .attribute(property, options = {}, &block) ⇒ Object (also: method_missing)
- .setup(prefix = "", &block) ⇒ Object
Class Attribute Details
.attr_mappings ⇒ Object
Returns the value of attribute attr_mappings.
11 12 13 |
# File 'lib/retort/rtorrent.rb', line 11 def attr_mappings @attr_mappings end |
.attributes ⇒ Object
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/retort/rtorrent.rb', line 11 def attributes @attributes end |
.attributes_raw ⇒ Object
Returns the value of attribute attributes_raw.
11 12 13 |
# File 'lib/retort/rtorrent.rb', line 11 def attributes_raw @attributes_raw end |
.prefix ⇒ Object
Returns the value of attribute prefix.
11 12 13 |
# File 'lib/retort/rtorrent.rb', line 11 def prefix @prefix end |
Class Method Details
.attribute(property, options = {}, &block) ⇒ Object Also known as: method_missing
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/retort/rtorrent.rb', line 21 def attribute(property, = {}, &block) type = [:type] method_name = [:name] || property method_name = "#{self.prefix}.#{method_name}" unless self.prefix.empty? self.attributes_raw[property] = method_name if TYPES.member? type #Syntax is 'to_*=$.....'. Example : 'to_date=$d.get_creation_date'. self.attributes[property] = "#{TYPES[type]}=$#{method_name}" property = "#{property}_raw" end self.attributes[property] = method_name end |
.setup(prefix = "", &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/retort/rtorrent.rb', line 13 def setup(prefix="", &block) self.prefix = prefix self.attributes = {} self.attributes_raw = {} instance_eval(&block) end |