Class: Fugle::Intraday::Meta Private

Inherits:
Object
  • Object
show all
Includes:
HTTP::API, Utils
Defined in:
lib/fugle/intraday/meta.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The Intraday Meta

Since:

  • 0.1.0

Defined Under Namespace

Classes: Price

Constant Summary collapse

STATES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

%w[Index Terminated Suspended Warrant].freeze
PERMITS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

%w[DayBuySell DaySellBuy ShortMargin ShortLend].freeze

Constants included from HTTP::API

HTTP::API::ENDPOINT, HTTP::API::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HTTP::API

included

Constructor Details

#initialize(data) ⇒ Meta

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Meta.

Since:

  • 0.1.0



28
29
30
31
32
33
34
35
36
# File 'lib/fugle/intraday/meta.rb', line 28

def initialize(data)
  load_boolean STATES, data, prefix: 'is'
  load_boolean PERMITS, data, prefix: 'can'

  @name = data['nameZhTw']
  @industry = data['industryZhTw']
  @type = data['typeZhTw']
  @price = Price.new(data)
end

Instance Attribute Details

#industryObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
# File 'lib/fugle/intraday/meta.rb', line 19

def industry
  @industry
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
# File 'lib/fugle/intraday/meta.rb', line 19

def name
  @name
end

#priceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
# File 'lib/fugle/intraday/meta.rb', line 19

def price
  @price
end

#typeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
# File 'lib/fugle/intraday/meta.rb', line 19

def type
  @type
end

Instance Method Details

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert to Hash

rubocop:disable Metrics/MethodLength

Returns:

  • (Hash)

    the response as hash

Since:

  • 0.1.0



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fugle/intraday/meta.rb', line 61

def to_h
  {
    name: @name,
    industry: @industry,
    type: @type,
    price: @price,
    is_index: index?,
    is_terminated: terminated?,
    is_suspended: suspended?,
    is_warrant: warrant?,
    can_day_buy_sell: day_buy_sell?,
    can_day_sell_buy: day_sell_buy?,
    can_short_margin: short_margin?,
    can_short_lend: short_lend?
  }
end

#to_json(*args) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert to JSON

Returns:

  • (String)

    the json string

Since:

  • 0.1.0



85
86
87
# File 'lib/fugle/intraday/meta.rb', line 85

def to_json(*args)
  to_h.to_json(*args)
end