Class: Paragraph
- Inherits:
-
Object
- Object
- Paragraph
- Defined in:
- lib/Models/Paragraph.rb
Defined Under Namespace
Classes: Iframe, Markup, MetaData, MixtapeMetadata
Instance Attribute Summary collapse
-
#href ⇒ Object
Returns the value of attribute href.
-
#iframe ⇒ Object
Returns the value of attribute iframe.
-
#markupLinks ⇒ Object
Returns the value of attribute markupLinks.
-
#markups ⇒ Object
Returns the value of attribute markups.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#mixtapeMetadata ⇒ Object
Returns the value of attribute mixtapeMetadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#oliIndex ⇒ Object
Returns the value of attribute oliIndex.
-
#orgText ⇒ Object
Returns the value of attribute orgText.
-
#postID ⇒ Object
Returns the value of attribute postID.
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(json, postID) ⇒ Paragraph
constructor
A new instance of Paragraph.
Constructor Details
#initialize(json, postID) ⇒ Paragraph
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/Models/Paragraph.rb', line 60 def initialize(json, postID) @name = json['name'] @text = json['text'] @orgText = json['text'] @type = json['type'] @href = json['href'] @postID = postID if json['metadata'].nil? = nil else = MetaData.new(json['metadata']) end if json['mixtapeMetadata'].nil? @mixtapeMetadata = nil else @mixtapeMetadata = MixtapeMetadata.new(json['mixtapeMetadata']) end if json['iframe'].nil? @iframe = nil else @iframe = Iframe.new(json['iframe']['mediaResource']) end if !json['markups'].nil? && json['markups'].length > 0 markups = [] json['markups'].each do |markup| markups.append(Markup.new(markup)) end @markups = markups links = json['markups'].select{ |markup| markup["type"] == "A" } if !links.nil? && links.length > 0 @markupLinks = links.map{ |link| link["href"] } end else @markups = nil end end |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def href @href end |
#iframe ⇒ Object
Returns the value of attribute iframe.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def iframe @iframe end |
#markupLinks ⇒ Object
Returns the value of attribute markupLinks.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def markupLinks @markupLinks end |
#markups ⇒ Object
Returns the value of attribute markups.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def markups @markups end |
#metadata ⇒ Object
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def end |
#mixtapeMetadata ⇒ Object
Returns the value of attribute mixtapeMetadata.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def mixtapeMetadata @mixtapeMetadata end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def name @name end |
#oliIndex ⇒ Object
Returns the value of attribute oliIndex.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def oliIndex @oliIndex end |
#orgText ⇒ Object
Returns the value of attribute orgText.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def orgText @orgText end |
#postID ⇒ Object
Returns the value of attribute postID.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def postID @postID end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def text @text end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/Models/Paragraph.rb', line 7 def type @type end |
Class Method Details
.makeBlankParagraph(postID) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/Models/Paragraph.rb', line 51 def self.makeBlankParagraph(postID) json = { "name" => "fakeBlankParagraph_#{SecureRandom.uuid}", "text" => "", "type" => PParser.getTypeString() } Paragraph.new(json, postID) end |