Class: FiddleFart::Plnkr
- Inherits:
-
Object
- Object
- FiddleFart::Plnkr
- Defined in:
- lib/fiddle_fart/plnkr.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 (also: #share_link)
-
#initialize(attrs = {}) ⇒ Plnkr
constructor
A new instance of Plnkr.
Constructor Details
#initialize(attrs = {}) ⇒ Plnkr
Returns a new instance of Plnkr.
5 6 7 |
# File 'lib/fiddle_fart/plnkr.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/plnkr.rb', line 3 def id @id end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/fiddle_fart/plnkr.rb', line 3 def username @username end |
Class Method Details
.parse(url) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fiddle_fart/plnkr.rb', line 9 def self.parse(url) obj = self.new if url.include?("embed.plnkr") host, domain, id, view = url.scan(/([^\/^:]+)/).flatten else host, domain, view, id = url.scan(/([^\/^:]+)/).flatten end obj.id = id.split("?").first obj end |
Instance Method Details
#as_json ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fiddle_fart/plnkr.rb', line 30 def as_json { edit_link: edit_link, embed_url: , share_link: share_link } end |
#edit_link ⇒ Object
20 21 22 |
# File 'lib/fiddle_fart/plnkr.rb', line 20 def edit_link "http://plnkr.co/edit/#{@id}" end |
#embed_url ⇒ Object Also known as:
24 25 26 |
# File 'lib/fiddle_fart/plnkr.rb', line 24 def "http://embed.plnkr.co/#{@id}/preview" end |