Class: RTransmission::Type
- Inherits:
-
Object
- Object
- RTransmission::Type
show all
- Defined in:
- lib/rtransmission/type.rb
Direct Known Subclasses
RTransmission::Types::Day, RTransmission::Types::Encryption, RTransmission::Types::Error, RTransmission::Types::Eta, RTransmission::Types::File, RTransmission::Types::FileStat, RTransmission::Types::Peer, RTransmission::Types::PeersFrom, RTransmission::Types::Priority, RTransmission::Types::SeedIdleMode, RTransmission::Types::SeedRatioMode, RTransmission::Types::Stats, RTransmission::Types::Status, RTransmission::Types::Time, RTransmission::Types::Tracker, RTransmission::Types::TrackerStat, RTransmission::Types::TrackerState, RTransmission::Types::TrafficStats
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Type
Returns a new instance of Type.
51
52
53
|
# File 'lib/rtransmission/type.rb', line 51
def initialize(hash)
@hash = hash
end
|
Class Method Details
.attribute(rpc_name, args = {}) ⇒ Object
.map(value, type) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/rtransmission/type.rb', line 29
def self.map(value, type)
if type
if type.class == Array
type = RTransmission::Type.type_to_class(type[0])
value.map! { |v| type.map(v) }
else
type = RTransmission::Type.type_to_class(type)
value = type.map(value)
end
end
value
end
|
.type_to_class(type) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/rtransmission/type.rb', line 7
def self.type_to_class(type)
type = type.to_s
type = '_' + type
type.gsub!(/_./) { |x| x[1].upcase }
RTransmission::Types.const_get(type)
end
|
.unmap(value, type) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rtransmission/type.rb', line 15
def self.unmap(value, type)
if type
if type.class == Array
type = RTransmission::Type.type_to_class(type[0])
value.map! { |v| type.unmap(v) }
else
type = RTransmission::Type.type_to_class(type)
value = type.unmap(value)
end
end
value
end
|