Class: Use0MK::ShortenedURI
- Inherits:
-
Object
- Object
- Use0MK::ShortenedURI
- Defined in:
- lib/use0mk.rb
Overview
Represents a shortened URI from 0.mk. It contains only the information retrieved by the API call to 0.mk. The volume of information with any API call is not consistent therefore any attribute of this class that is nil
or empty
should be ignored.
The origin (the API call which generated the object of this class) of this object can be tracked with the origin
attribute. The origin is a Symbol which is a member of ORIGINS.
It is not a good idea to create instances of this class by hand, as it contains only data available from API calls to 0.mk.
Instance Attribute Summary collapse
-
#delete_code ⇒ String?
readonly
the deletion code.
-
#delete_uri ⇒ String?
readonly
the deletion URI.
-
#deleted ⇒ true, false
readonly
whether this URI is deleted.
-
#long_uri ⇒ String?
readonly
the long URI.
-
#origin ⇒ Symbol
readonly
a member of ORIGINS.
-
#short_name ⇒ String?
readonly
the short name (
http://0.mk/short_name
). -
#short_uri ⇒ String?
readonly
the shortened URI.
-
#stats_uri ⇒ String?
readonly
the stats URI.
-
#title ⇒ String?
readonly
the document title of the long URI.
Instance Method Summary collapse
-
#delete ⇒ true, false
Deletes the shortened URI.
-
#initialize(origin, attributes = {}) ⇒ ShortenedURI
constructor
Initializes this class.
Constructor Details
#initialize(origin, attributes = {}) ⇒ ShortenedURI
Initializes this class. Usually called from either shorten
or preview
.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/use0mk.rb', line 183 def initialize(origin, attributes = {}) if !(Use0MK::ORIGINS.member? origin) raise ArgumentError, "origin should be a member of Use0MK::ORIGINS" end @origin = origin @deleted = @origin != :shorten @long_uri = attributes[:long_uri] @short_uri = attributes[:short_uri] @short_name = attributes[:short_name] @stats_uri = attributes[:stats_uri] @title = attributes[:title] @delete_uri = attributes[:delete_uri] @delete_code = attributes[:delete_code] end |
Instance Attribute Details
#delete_code ⇒ String? (readonly)
the deletion code
174 175 176 |
# File 'lib/use0mk.rb', line 174 def delete_code @delete_code end |
#delete_uri ⇒ String? (readonly)
the deletion URI
171 172 173 |
# File 'lib/use0mk.rb', line 171 def delete_uri @delete_uri end |
#deleted ⇒ true, false (readonly)
whether this URI is deleted
177 178 179 |
# File 'lib/use0mk.rb', line 177 def deleted @deleted end |
#long_uri ⇒ String? (readonly)
the long URI
156 157 158 |
# File 'lib/use0mk.rb', line 156 def long_uri @long_uri end |
#origin ⇒ Symbol (readonly)
a member of ORIGINS
153 154 155 |
# File 'lib/use0mk.rb', line 153 def origin @origin end |
#short_name ⇒ String? (readonly)
the short name (http://0.mk/short_name
)
162 163 164 |
# File 'lib/use0mk.rb', line 162 def short_name @short_name end |
#short_uri ⇒ String? (readonly)
the shortened URI
159 160 161 |
# File 'lib/use0mk.rb', line 159 def short_uri @short_uri end |
#stats_uri ⇒ String? (readonly)
the stats URI
165 166 167 |
# File 'lib/use0mk.rb', line 165 def stats_uri @stats_uri end |
#title ⇒ String? (readonly)
the document title of the long URI
168 169 170 |
# File 'lib/use0mk.rb', line 168 def title @title end |
Instance Method Details
#delete ⇒ true, false
Deletes the shortened URI. This method calls Interface.delete internally.
205 206 207 208 209 210 211 |
# File 'lib/use0mk.rb', line 205 def delete if @deleted return false end @deleted = Use0MK::Interface.delete(@delete_uri, @delete_code) end |