Class: KudagoClient::Entities::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/kudago_client/entities/agent.rb

Defined Under Namespace

Classes: Participation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lang:, text_format: "html", id: nil, title: nil, slug: nil, favorites_count: nil, comments_count: nil, description: nil, body_text: nil, site_url: nil, disable_comments: nil, ctype: nil, images: nil, agent_type: nil, rank: nil, participations: nil, is_stub: nil) ⇒ Agent

Returns a new instance of Agent.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/kudago_client/entities/agent.rb', line 28

def initialize(
  lang:, text_format: "html", id: nil, title: nil, slug: nil, favorites_count: nil, comments_count: nil,
  description: nil, body_text: nil, site_url: nil, disable_comments: nil, ctype: nil, images: nil,
  agent_type: nil, rank: nil, participations: nil, is_stub: nil
)
  @lang = lang
  @id = id

  @agent_type = agent_type
  @body_text = body_text
  @comments_count = comments_count
  @ctype = ctype
  @description = description
  @disable_comments = disable_comments
  @favorites_count = favorites_count
  @is_stub = is_stub
  @rank = rank
  @site_url = site_url
  @slug = slug
  @text_format = text_format
  @title = title

  @images = images&.map do |image|
    KudagoClient::Entities::Image.new(image: image[:image], thumbnails: image[:thumbnails], source: image[:source])
  end
  @participations = participations&.map do |participation|
    Participation.new(
      Role.new(**participation[:role], lang: lang),
      (participation[:item][:ctype] == "event") ? Event.new(**participation[:item].except(:ctype), lang: lang) : nil
    )
  end
end

Instance Attribute Details

#agent_typeObject (readonly)

Returns the value of attribute agent_type.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def agent_type
  @agent_type
end

#body_textObject (readonly)

Returns the value of attribute body_text.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def body_text
  @body_text
end

#comments_countObject (readonly)

Returns the value of attribute comments_count.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def comments_count
  @comments_count
end

#ctypeObject (readonly)

Returns the value of attribute ctype.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def ctype
  @ctype
end

#descriptionObject (readonly)

Returns the value of attribute description.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def description
  @description
end

#disable_commentsObject (readonly)

Returns the value of attribute disable_comments.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def disable_comments
  @disable_comments
end

#favorites_countObject (readonly)

Returns the value of attribute favorites_count.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def favorites_count
  @favorites_count
end

#idObject (readonly)

Returns the value of attribute id.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def images
  @images
end

#is_stubObject (readonly)

Returns the value of attribute is_stub.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def is_stub
  @is_stub
end

#langObject (readonly)

Returns the value of attribute lang.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def lang
  @lang
end

#participationsObject (readonly)

Returns the value of attribute participations.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def participations
  @participations
end

#rankObject (readonly)

Returns the value of attribute rank.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def rank
  @rank
end

#site_urlObject (readonly)

Returns the value of attribute site_url.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def site_url
  @site_url
end

#slugObject (readonly)

Returns the value of attribute slug.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def slug
  @slug
end

#text_formatObject (readonly)

Returns the value of attribute text_format.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def text_format
  @text_format
end

#titleObject (readonly)

Returns the value of attribute title.



25
26
27
# File 'lib/kudago_client/entities/agent.rb', line 25

def title
  @title
end