Class: Paragraph

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

Defined Under Namespace

Classes: Iframe, MetaData, MixtapeMetadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, postID, resource) ⇒ Paragraph



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/Models/Paragraph.rb', line 47

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

    if json['metadata'].nil?
        @metadata = nil
    else
        @metadata = MetaData.new(resource[json['metadata']['__ref']])
    end

    if json['mixtapeMetadata'].nil?
        @mixtapeMetadata = nil
    else
        @mixtapeMetadata = MixtapeMetadata.new(json['mixtapeMetadata'])
    end

    if json['iframe'].nil?
        @iframe = nil
    else
        @iframe = Iframe.new(resource[json['iframe']['mediaResource']['__ref']])
    end
    
    if !json['markups'].nil? && json['markups'].length > 0
        links = json['markups'].select{ |markup| markup["type"] == "A" }
        if !links.nil? && links.length > 0
            @markupLinks = links.map{ |link| link["href"] }
        end
        @hasMarkup = true
    else
        @hasMarkup = false
    end
end

Instance Attribute Details

#hasMarkupObject

Returns the value of attribute hasMarkup.



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

def hasMarkup
  @hasMarkup
end

#hrefObject

Returns the value of attribute href.



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

def href
  @href
end

#iframeObject

Returns the value of attribute iframe.



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

def iframe
  @iframe
end

Returns the value of attribute markupLinks.



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

def markupLinks
  @markupLinks
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#mixtapeMetadataObject

Returns the value of attribute mixtapeMetadata.



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

def 
  @mixtapeMetadata
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#oliIndexObject

Returns the value of attribute oliIndex.



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

def oliIndex
  @oliIndex
end

#postIDObject

Returns the value of attribute postID.



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

def postID
  @postID
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#typeObject

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



38
39
40
41
42
43
44
45
# File 'lib/Models/Paragraph.rb', line 38

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