Class: Wikidatum::Sitelink

Inherits:
Object
  • Object
show all
Defined in:
lib/wikidatum/sitelink.rb

Overview

Wikidatum::Sitelinks represent associated sitelinks on a Wikidata item, for example the associated English Wikipedia article.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#badgesArray<String> (readonly)

Returns An array of badges, given as item IDs (e.g. ['Q123', 'Q124']).

Returns:

  • (Array<String>)

    An array of badges, given as item IDs (e.g. ['Q123', 'Q124']).



13
14
15
# File 'lib/wikidatum/sitelink.rb', line 13

def badges
  @badges
end

#siteString (readonly)

Returns The shortcode for the given site (e.g. ‘enwiki’, ‘commons’, etc.).

Returns:

  • (String)

    The shortcode for the given site (e.g. ‘enwiki’, ‘commons’, etc.).



7
8
9
# File 'lib/wikidatum/sitelink.rb', line 7

def site
  @site
end

#titleString (readonly)

Returns The title of the page in the associated Wikimedia site.

Returns:

  • (String)

    The title of the page in the associated Wikimedia site.



10
11
12
# File 'lib/wikidatum/sitelink.rb', line 10

def title
  @title
end

Instance Method Details

#inspectString

Returns:

  • (String)


37
38
39
# File 'lib/wikidatum/sitelink.rb', line 37

def inspect
  "<Wikidatum::Sitelink site=#{@site.inspect} title=#{@title.inspect} badges=#{@badges.inspect}>"
end

#to_hHash

Returns:

  • (Hash)


28
29
30
31
32
33
34
# File 'lib/wikidatum/sitelink.rb', line 28

def to_h
  {
    site: @site,
    title: @title,
    badges: @badges
  }
end