Class: TumblRb::Blog
- Inherits:
-
Object
- Object
- TumblRb::Blog
- Defined in:
- lib/tumbl_rb/blog.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(blog) ⇒ Blog
constructor
A new instance of Blog.
-
#to_s ⇒ String
Returns the hostname.
-
#url ⇒ String
Returns the url.
Constructor Details
#initialize(blog) ⇒ Blog
Returns a new instance of Blog.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tumbl_rb/blog.rb', line 5 def initialize(blog) case blog when String if blog.include?(".") @hostname = blog @username = blog.include?(".tumblr.com") ? blog.chomp(".tumblr.com") : nil else @hostname = "#{blog}.tumblr.com" @username = blog end when Hash @hostname = blog[:hostname] ||= blog[:blog] @username = blog[:username] ||= blog[:user] end end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname.
3 4 5 |
# File 'lib/tumbl_rb/blog.rb', line 3 def hostname @hostname end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/tumbl_rb/blog.rb', line 3 def username @username end |
Instance Method Details
#to_s ⇒ String
Returns the hostname
24 25 26 |
# File 'lib/tumbl_rb/blog.rb', line 24 def to_s @hostname end |
#url ⇒ String
Returns the url
31 32 33 |
# File 'lib/tumbl_rb/blog.rb', line 31 def url "http://#{@hostname}" end |