Class: Profile
- Inherits:
-
Object
show all
- Defined in:
- lib/tRuTag.rb
Instance Attribute Summary collapse
-
#tbin ⇒ Object
readonly
To create a profile object you will need to pass in a hash containing the following: type: classname of the corresponding site username: username if this is for input pwd: if it is necessary for the site.
Instance Method Summary
collapse
Constructor Details
#initialize(prohash) ⇒ Profile
Returns a new instance of Profile.
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/tRuTag.rb', line 134
def initialize(prohash)
begin
case prohash['type']
when '43Things', '43Cosas', '43Cose', '43Choses', '43Dinge', '43Coisas'
@site = RobotCoop.new(prohash)
when 'Yahoo2'
@site = Y2.new(prohash)
when 'Jots'
@site = Jts.new(prohash)
when 'Flickr'
@site = Flkr.new(prohash)
else
@site = Site.new(prohash)
end
rescue ArgumentError
Trutag::loggit(2, %{#{$!}})
end
if prohash.fetch('mode', 0) == 1
begin
add_tags(prohash['tbin'])
rescue SocketError
Trutag::loggit(2, %{IO failed: #{@site.attrib['sitename']}})
rescue Timeout::Error
Trutag::loggit(2, %{Timeout:#{@site.attrib['sitename']}})
rescue
Trutag::loggit(2, %{})
end
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
188
189
190
191
192
193
194
|
# File 'lib/tRuTag.rb', line 188
def method_missing( name, *args )
begin
@site.__send__( name, *args )
rescue NoMethodError
Trutag::loggit(1, %{Could not find method Site.#{name}})
end
end
|
Instance Attribute Details
#tbin ⇒ Object
To create a profile object you will need to pass in a hash containing the following: type: classname of the corresponding site username: username if this is for input pwd: if it is necessary for the site. offline: (optional) The XML file to use instad of the URL
132
133
134
|
# File 'lib/tRuTag.rb', line 132
def tbin
@tbin
end
|
Instance Method Details
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/tRuTag.rb', line 171
def add_tags(tbin)
if tbin == nil
tbin = Hash.new
end
begin
@site.add_tags(tbin)
rescue SocketError
Trutag::loggit(2, %{IO failed: #{@site.attrib['sitename']} #{$!}})
end
end
|
183
184
185
|
# File 'lib/tRuTag.rb', line 183
def base_all_tags_url
%{http://#{@site.attrib['url']}#{@site.attrib['all_tags_path']}}
end
|
#space_replace(tag) ⇒ Object
167
168
169
|
# File 'lib/tRuTag.rb', line 167
def space_replace(tag)
TagCloudMaker.space_to_plus(tag, @site.attrib['space_replacement'])
end
|