Class: FiddleFart::Codepen
- Inherits:
-
Object
- Object
- FiddleFart::Codepen
- Defined in:
- lib/fiddle_fart/codepen.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #edit_link ⇒ Object
- #embed_url ⇒ Object
-
#initialize(attrs = {}) ⇒ Codepen
constructor
A new instance of Codepen.
- #share_link ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Codepen
Returns a new instance of Codepen.
5 6 7 |
# File 'lib/fiddle_fart/codepen.rb', line 5 def initialize(attrs={}) attrs.each { |k,v| instance_variable_set("@#{k}", v) } end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/fiddle_fart/codepen.rb', line 3 def id @id end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/fiddle_fart/codepen.rb', line 3 def username @username end |
Class Method Details
.parse(url) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fiddle_fart/codepen.rb', line 9 def self.parse(url) obj = self.new host, domain, username, view, id = url.scan(/([^\/^:]+)/).flatten obj.id = id obj.username = username obj end |
Instance Method Details
#as_json ⇒ Object
29 30 31 |
# File 'lib/fiddle_fart/codepen.rb', line 29 def as_json super end |
#edit_link ⇒ Object
21 22 23 |
# File 'lib/fiddle_fart/codepen.rb', line 21 def edit_link "http://codepen.io/#{@username}/pen/#{@id}" end |
#embed_url ⇒ Object
25 26 27 |
# File 'lib/fiddle_fart/codepen.rb', line 25 def nil end |
#share_link ⇒ Object
17 18 19 |
# File 'lib/fiddle_fart/codepen.rb', line 17 def share_link "http://codepen.io/#{@username}/full/#{@id}" end |