Class: JapaneseAddressParser::Fetcher::Response

Inherits:
Data
  • Object
show all
Defined in:
lib/japanese_address_parser/fetcher.rb,
lib/japanese_address_parser/fetcher.rb,
sig/fetcher.rbs

Overview

取得結果。JS の FetchResponseLike { json(), text(), ok } に対応する。 body は UTF-8 の生文字列、ok は取得成功フラグ。

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



19
20
21
# File 'lib/japanese_address_parser/fetcher.rb', line 19

def body
  @body
end

#okObject (readonly)

Returns the value of attribute ok

Returns:

  • (Object)

    the current value of ok



19
20
21
# File 'lib/japanese_address_parser/fetcher.rb', line 19

def ok
  @ok
end

Class Method Details

.new(body:, ok:) ⇒ Response .new(body, ok) ⇒ Response

Overloads:

  • .new(body:, ok:) ⇒ Response

    Parameters:

    • body: (String)
    • ok: (Boolean)

    Returns:

  • .new(body, ok) ⇒ Response

    Parameters:

    • body (String)
    • ok (Boolean)

    Returns:



8
9
# File 'sig/fetcher.rbs', line 8

def self.new: (body: String, ok: bool) -> Response
| (String body, bool ok) -> Response

Instance Method Details

#jsonObject

JS: json: async () => JSON.parse(contents.toString('utf-8'))

Returns:

  • (Object)


24
25
26
# File 'lib/japanese_address_parser/fetcher.rb', line 24

def json
  ::JSON.parse(body)
end

#textString

JS: text: async () => contents.toString('utf-8')

Returns:

  • (String)


29
30
31
# File 'lib/japanese_address_parser/fetcher.rb', line 29

def text
  body
end