Class: Paragraph

Inherits:
Object
  • Object
show all
Defined in:
lib/Models/Paragraph.rb

Defined Under Namespace

Classes: Iframe, Markup, MetaData, MixtapeMetadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, postID) ⇒ Paragraph

Returns a new instance of Paragraph.



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
101
102
103
104
# File 'lib/Models/Paragraph.rb', line 61

def initialize(json, postID)
    @name = json['name']
    @text = json['text']
    @orgText = json['text']
    @type = json['type']
    @href = json['href']
    @postID = postID

    orgTextWithEscape = Helper.escapeMarkdown(json['text'])
    @orgTextWithEscape = orgTextWithEscape

    if json['metadata'].nil?
        @metadata = nil
    else
        @metadata = 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

#hrefObject

Returns the value of attribute href.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def href
  @href
end

#iframeObject

Returns the value of attribute iframe.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def iframe
  @iframe
end

Returns the value of attribute markupLinks.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def markupLinks
  @markupLinks
end

#markupsObject

Returns the value of attribute markups.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def markups
  @markups
end

#metadataObject

Returns the value of attribute metadata.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def 
  @metadata
end

#mixtapeMetadataObject

Returns the value of attribute mixtapeMetadata.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def 
  @mixtapeMetadata
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def name
  @name
end

#oliIndexObject

Returns the value of attribute oliIndex.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def oliIndex
  @oliIndex
end

#orgTextObject

Returns the value of attribute orgText.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def orgText
  @orgText
end

#orgTextWithEscapeObject

Returns the value of attribute orgTextWithEscape.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def orgTextWithEscape
  @orgTextWithEscape
end

#postIDObject

Returns the value of attribute postID.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def postID
  @postID
end

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def text
  @text
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/Models/Paragraph.rb', line 8

def type
  @type
end

Class Method Details

.makeBlankParagraph(postID) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/Models/Paragraph.rb', line 52

def self.makeBlankParagraph(postID)
    json = {
        "name" => "fakeBlankParagraph_#{SecureRandom.uuid}",
        "text" => "",
        "type" => PParser.getTypeString()
    }
    Paragraph.new(json, postID)
end