Class: TecDoc::GenericArticle

Inherits:
Object
  • Object
show all
Defined in:
lib/tec_doc/generic_article.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, scope = {}) ⇒ GenericArticle

Returns a new instance of GenericArticle.



30
31
32
33
34
# File 'lib/tec_doc/generic_article.rb', line 30

def initialize(attributes = {}, scope = {})
  @id    = (attributes[:id] || attributes[:generic_article_id]).to_i
  @name  = attributes[:article_norm_name]
  @scope = scope
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/tec_doc/generic_article.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/tec_doc/generic_article.rb', line 3

def name
  @name
end

#scopeObject

Returns the value of attribute scope.



4
5
6
# File 'lib/tec_doc/generic_article.rb', line 4

def scope
  @scope
end

Class Method Details

.all(options = {}) ⇒ Array<TecDoc::GenericArticle>

Get generic articles

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :assembly_group_node_id (Integer) — default: optional
  • :generic_article_id (LongList) — default: optional
  • :brand_no (LongList)

    result of brand selection (optional)

  • :linking_target_type (String)
    • “C”, “M”, “A”, “K”, “U”

  • :linking_target_id (Integer)
    • null if “U”

  • :result_mode (Integer)
    • 1: Distinct brand numbers, 2: Distinct generic articles, 3: Both (optional)

  • :sort_mode (Integer)
    • 1: Brand name, 2: Article norm name (optional)

Returns:



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tec_doc/generic_article.rb', line 18

def self.all(options = {})
  options[:result_mode] = 2
  options[:sort_mode] = 2
  options = {
    :lang => I18n.locale.to_s,
    :country => TecDoc.client.country
  }.merge(options)
  TecDoc.client.request(:get_generic_articles_by_manufacturer6, options).map do |attributes|
    new(attributes, options)
  end
end

Instance Method Details

#articles(options = {}) ⇒ Object

Generic article linked articles



37
38
39
40
41
42
43
44
45
# File 'lib/tec_doc/generic_article.rb', line 37

def articles(options = {})
  options = {
    :linking_target_type => scope[:linking_target_type],
    :linking_target_id   => scope[:linking_target_id]
  }.merge(options).merge({
    :generic_article_id => { :array => { :id => [id] } }
  })
  Article.all(options)
end