Class: DJNML::Modification::Mdata

Inherits:
Object
  • Object
show all
Defined in:
lib/djnml/modification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Mdata

Returns a new instance of Mdata.



120
121
122
123
124
125
# File 'lib/djnml/modification.rb', line 120

def initialize(data = nil)
  return unless data

  initialize_from_xml(data) if data.is_a?(Nokogiri::XML::Element)
  initialize_from_hash(data) if data.is_a?(Hash)
end

Instance Attribute Details

#company_codeObject (readonly)

Returns the value of attribute company_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def company_code
  @company_code
end

#content_codeObject (readonly)

Returns the value of attribute content_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def content_code
  @content_code
end

#function_codeObject (readonly)

Returns the value of attribute function_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def function_code
  @function_code
end

#geo_codeObject (readonly)

Returns the value of attribute geo_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def geo_code
  @geo_code
end

#government_codeObject (readonly)

Returns the value of attribute government_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def government_code
  @government_code
end

#industry_codeObject (readonly)

Returns the value of attribute industry_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def industry_code
  @industry_code
end

#isin_codeObject (readonly)

Returns the value of attribute isin_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def isin_code
  @isin_code
end

#journal_codeObject (readonly)

Returns the value of attribute journal_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def journal_code
  @journal_code
end

#market_codeObject (readonly)

Returns the value of attribute market_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def market_code
  @market_code
end

#page_codeObject (readonly)

Returns the value of attribute page_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def page_code
  @page_code
end

#product_codeObject (readonly)

Returns the value of attribute product_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def product_code
  @product_code
end

#routing_codeObject (readonly)

Returns the value of attribute routing_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def routing_code
  @routing_code
end

#stat_codeObject (readonly)

Returns the value of attribute stat_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def stat_code
  @stat_code
end

#subject_codeObject (readonly)

Returns the value of attribute subject_code.



111
112
113
# File 'lib/djnml/modification.rb', line 111

def subject_code
  @subject_code
end

Class Method Details

.from_hash(data) ⇒ Object



116
117
118
# File 'lib/djnml/modification.rb', line 116

def self.from_hash(data)
  self.new(data) if data.is_a?(Hash)
end

Instance Method Details

#initialize_from_hash(data) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/djnml/modification.rb', line 127

def initialize_from_hash(data)
  @company_code = data['company_code']
  @isin_code = data['isin_code']
  @page_code = data['page_code']
  @industry_code = data['industry_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @government_code = data['government_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @subject_code = data['subject_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @market_code = data['market_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @geo_code = data['geo_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @stat_code = data['stat_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @journal_code = data['journal_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @routing_code = data['routing_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @function_code = data['function_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
  @product_code = data['product_code'].map { |c| ::DJNML::Codes.new(c['symbol']) }
end

#initialize_from_xml(xml) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/djnml/modification.rb', line 143

def initialize_from_xml(xml)
  # company
  #
  if tag = xml.search('djn-coding/djn-company/c')
    @company_code = tag.map { |tag| tag.text.strip }
    tag = nil
  end

  # isin
  #
  if tag = xml.search('djn-coding/djn-isin/c')
    @isin_code = tag.map { |tag| tag.text.strip }
    tag = nil
  end

  # industry
  #
  if tag = xml.search('djn-coding/djn-industry/c')
    @industry_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # government
  #
  if tag = xml.search('djn-coding/djn-government/c')
    @government_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # page
  #
  if tag = xml.search('djn-coding/djn-page/c')
    @page_code = tag.map { tag.text.strip }
    tag = nil
  end

  # subject
  #
  if tag = xml.search('djn-coding/djn-subject/c')
    @subject_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # market
  #
  if tag = xml.search('djn-coding/djn-market/c')
    @market_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # product
  #
  if tag = xml.search('djn-coding/djn-product/c')
    @product_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # geo
  #
  if tag = xml.search('djn-coding/djn-geo/c')
    @geo_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # stat
  #
  if tag = xml.search('djn-coding/djn-stat/c')
    @stat_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # journal
  #
  if tag = xml.search('djn-coding/djn-journal/c')
    @journal_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # routing
  #
  if tag = xml.search('djn-coding/djn-routing/c')
    @routing_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # content
  #
  if tag = xml.search('djn-coding/djn-content/c')
    @content_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end

  # function
  #
  if tag = xml.search('djn-coding/djn-function/c')
    @function_code = tag.map { |tag| ::DJNML::Codes.new(tag.text.strip) }
    tag = nil
  end
end