Class: Cwsrb::Language

Inherits:
Object
  • Object
show all
Defined in:
lib/cwsrb/data.rb

Overview

The Language class represents a language of ConWorkShop.

Defined Under Namespace

Classes: Status, Type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: '', name: '', native_name: '', ipa: '', type: nil, owners: [], overview: '', public: true, status: '', registered: Time.now, word_count: 0, karma: [0, 0]) ⇒ Language

Initializes a new Language instance with an options hash.

Parameters:

  • code (String) (defaults to: '')

    The three-character language code. Defaults to an empty string.

  • name (String) (defaults to: '')

    The language's name. Defaults to an empty string.

  • native_name (String) (defaults to: '')

    The language's autonym (native name). Defaults to an empty string.

  • ipa (String) (defaults to: '')

    The IPA transcription for the autonym. Defaults to an empty string.

  • type (Type) (defaults to: nil)

    The language's type. Defaults to nil.

  • owners (Array<String>) (defaults to: [])

    The owner plus shared users of this language. The first element must be the original owner.

  • overview (String) (defaults to: '')

    The overview, about me section, or bio, of this language. Defaults to an empty string.

  • public (Boolean) (defaults to: true)

    Whether or not this language's dictionary is public. Defaults to true.

  • status (Status) (defaults to: '')

    The language's status. Defaults to nil.

  • registered (Time) (defaults to: Time.now)

    When the language was registered. Defaults to the current time.

  • word_count (Integer) (defaults to: 0)

    The amount of words this language has. Defaults to 0.

  • karma (Array<(Integer, Integer)>) (defaults to: [0, 0])

    The language's karma counts. The first is upvotes, the second is downvotes. Defaults to zero for both.


178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/cwsrb/data.rb', line 178

def initialize(code: '', name: '', native_name: '', ipa: '', type: nil,
               owners: [], overview: '', public: true, status: '',
               registered: Time.now, word_count: 0, karma: [0, 0])
  @code = code
  @name = name
  @native_name = native_name
  @ipa = ipa
  @type = type
  @owners = owners
  @overview = overview
  @public = public
  @status = status
  @registered = registered
  @word_count = word_count
  @karma = karma
end

Instance Attribute Details

#codeString (readonly)

Returns The three-character language code.

Returns:

  • (String)

    The three-character language code.


117
118
119
# File 'lib/cwsrb/data.rb', line 117

def code
  @code
end

#ipaString (readonly)

Returns The IPA transcription for the language's native_name.

Returns:

  • (String)

    The IPA transcription for the language's native_name


126
127
128
# File 'lib/cwsrb/data.rb', line 126

def ipa
  @ipa
end

#karmaArray<(Integer, Integer)> (readonly)

Returns The language's karma counts; first one is upvotes and second one is downvotes.

Returns:

  • (Array<(Integer, Integer)>)

    The language's karma counts; first one is upvotes and second one is downvotes.


152
153
154
# File 'lib/cwsrb/data.rb', line 152

def karma
  @karma
end

#nameString (readonly)

Returns The language's name.

Returns:

  • (String)

    The language's name.


120
121
122
# File 'lib/cwsrb/data.rb', line 120

def name
  @name
end

#native_nameString (readonly)

Returns The language's autonym (native name).

Returns:

  • (String)

    The language's autonym (native name).


123
124
125
# File 'lib/cwsrb/data.rb', line 123

def native_name
  @native_name
end

#overviewString (readonly)

Returns The overview, about section or bio, of this language.

Returns:

  • (String)

    The overview, about section or bio, of this language.


136
137
138
# File 'lib/cwsrb/data.rb', line 136

def overview
  @overview
end

#ownersArray<String> (readonly)

Returns The owner plus shared users of this language. The first element is the original owner.

Returns:

  • (Array<String>)

    The owner plus shared users of this language. The first element is the original owner.


133
134
135
# File 'lib/cwsrb/data.rb', line 133

def owners
  @owners
end

#publicBoolean (readonly)

Returns Whether or not this language's dictionary is public.

Returns:

  • (Boolean)

    Whether or not this language's dictionary is public.


139
140
141
# File 'lib/cwsrb/data.rb', line 139

def public
  @public
end

#registeredTime (readonly)

Returns The time at which the language was registered.

Returns:

  • (Time)

    The time at which the language was registered.


145
146
147
# File 'lib/cwsrb/data.rb', line 145

def registered
  @registered
end

#statusLanguage::Status (readonly)

Returns The language's status.

Returns:


142
143
144
# File 'lib/cwsrb/data.rb', line 142

def status
  @status
end

#typeLanguage::Type (readonly)

Returns The language's type.

Returns:


129
130
131
# File 'lib/cwsrb/data.rb', line 129

def type
  @type
end

#word_countInteger (readonly)

Returns The word count for this language.

Returns:

  • (Integer)

    The word count for this language.


148
149
150
# File 'lib/cwsrb/data.rb', line 148

def word_count
  @word_count
end

Instance Method Details

Generates a CWS link to this language.

Returns:

  • (String)

    The generated link.


197
198
199
# File 'lib/cwsrb/data.rb', line 197

def generate_link
  CWS_BASE + "/view_language.php?l=#{@code}"
end

#inspectString

inspect method, with all of Language's attributes.

Returns:

  • (String)

    A more meaningful output than that of the default


204
205
206
207
208
209
# File 'lib/cwsrb/data.rb', line 204

def inspect
  "<Language code=#{@code} name=#{@name} native_name=#{@native_name} " \
    "ipa=#{@ipa} type=#{@type} owners=#{@owners} overview=#{@overview} " \
    "public=#{@public} status=#{@status} registered=#{@registered} " \
    "word_count=#{@word_count} karma=#{@karma}>"
end