Class: Transmission::Fields

Inherits:
Object
  • Object
show all
Extended by:
Utils
Defined in:
lib/transmission/fields.rb,
lib/transmission/fields/session_get.rb,
lib/transmission/fields/torrent_get.rb,
lib/transmission/fields/session_stats.rb

Direct Known Subclasses

SessionGet, SessionStats, TorrentGet

Defined Under Namespace

Classes: InvalidField, SessionGet, SessionStats, TorrentGet

Constant Summary collapse

ATTRIBUTES =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

is_valid_key?, option_key, option_keys

Constructor Details

#initialize(fields = nil) ⇒ Fields

Returns a new instance of Fields.



14
15
16
17
18
19
20
21
22
23
# File 'lib/transmission/fields.rb', line 14

def initialize(fields = nil)
  @fields = fields.inject([]) do |fields, field|
    found = self.class::ATTRIBUTES.select { |attr| attr[:field] == field}
    raise Transmission::Fields::InvalidField, field if found.empty?
    fields << field
  end if fields
  @fields = self.class::ATTRIBUTES.collect do |key|
    key[:field]
  end if fields.nil?
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



10
11
12
# File 'lib/transmission/fields.rb', line 10

def fields
  @fields
end

Class Method Details

.is_valid?(key) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/transmission/fields.rb', line 32

def is_valid?(key)
  is_valid_key? key, self::ATTRIBUTES
end

.real_key(key) ⇒ Object



36
37
38
# File 'lib/transmission/fields.rb', line 36

def real_key(key)
  option_key key, self::ATTRIBUTES
end

Instance Method Details

#to_fieldsObject



25
26
27
# File 'lib/transmission/fields.rb', line 25

def to_fields
  @fields
end