Class: SE::API::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/se/api/types/comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_json) ⇒ Comment

Returns a new instance of Comment.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/se/api/types/comment.rb', line 9

def initialize(item_json)
  @json = Hash(item_json)
  @body = @json["body"]
  @body_markdown = @json["body_markdown"]
  @link = @json["link"]
  @edited = (@json["edited"] == "true")
  @post_id = @json["post_id"].to_i
  @post_type = @json["post_type"]
  @score = @json["score"].to_i
  @type = @json["post_type"]
  @id = @json["comment_id"].to_i
  @created_at = @json["creation_date"]
  @author = User.new(@json["owner"])
end

Instance Attribute Details

#authorObject (readonly) Also known as: user, owner

Returns the value of attribute author.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def author
  @author
end

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def body
  @body
end

#body_markdownObject (readonly)

Returns the value of attribute body_markdown.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def body_markdown
  @body_markdown
end

#created_atObject (readonly) Also known as: creation_date

Returns the value of attribute created_at.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def created_at
  @created_at
end

#editedObject (readonly)

Returns the value of attribute edited.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def edited
  @edited
end

#idObject (readonly) Also known as: comment_id

Returns the value of attribute id.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def id
  @id
end

#jsonObject (readonly)

Returns the value of attribute json.



7
8
9
# File 'lib/se/api/types/comment.rb', line 7

def json
  @json
end

Returns the value of attribute link.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def link
  @link
end

#post_idObject (readonly)

Returns the value of attribute post_id.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def post_id
  @post_id
end

#post_typeObject (readonly)

Returns the value of attribute post_type.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def post_type
  @post_type
end

#scoreObject (readonly)

Returns the value of attribute score.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def score
  @score
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/se/api/types/comment.rb', line 6

def type
  @type
end