Class: Ferrum::Network::Request

Inherits:
Object
  • Object
show all
Includes:
RequestParams
Defined in:
lib/ferrum/network/request.rb

Overview

Instance Method Summary collapse

Methods included from RequestParams

#headers, #method, #post_data, #url, #url_fragment

Constructor Details

#initialize(params) ⇒ Request

Initializes the request object.

Parameters:

  • params (Hash{String => Object})

    The parsed JSON attributes.



21
22
23
24
# File 'lib/ferrum/network/request.rb', line 21

def initialize(params)
  @params = params
  @request = @params["request"]
end

Instance Method Details

#frame_idString

The frame ID of the request.

Returns:

  • (String)


70
71
72
# File 'lib/ferrum/network/request.rb', line 70

def frame_id
  @params["frameId"]
end

#idString

The request ID.

Returns:

  • (String)


31
32
33
# File 'lib/ferrum/network/request.rb', line 31

def id
  @params["requestId"]
end

#loader_idString

The loader ID of the request.

Returns:

  • (String)


79
80
81
# File 'lib/ferrum/network/request.rb', line 79

def loader_id
  @params["loaderId"]
end

#ping?Boolean

Determines if a request is of type ping.

Returns:

  • (Boolean)


97
98
99
# File 'lib/ferrum/network/request.rb', line 97

def ping?
  type?("ping")
end

#timeTime

The request timestamp.

Returns:

  • (Time)


88
89
90
# File 'lib/ferrum/network/request.rb', line 88

def time
  @time ||= Time.strptime(@params["wallTime"].to_s, "%s")
end

#to_hHash{String => Object}

Converts the request to a Hash.

Returns:

  • (Hash{String => Object})

    The params of the request.



107
108
109
# File 'lib/ferrum/network/request.rb', line 107

def to_h
  @params
end

#typeString

The request resouce type.

Returns:

  • (String)


40
41
42
# File 'lib/ferrum/network/request.rb', line 40

def type
  @params["type"]
end

#type?(value) ⇒ Boolean

Determines if the request is of the given type.

Parameters:

  • value (String, Symbol)

    The type value to compare against.

Returns:

  • (Boolean)


52
53
54
# File 'lib/ferrum/network/request.rb', line 52

def type?(value)
  type.downcase == value.to_s.downcase
end

#xhr?Boolean

Determines if the request is XHR.

Returns:

  • (Boolean)


61
62
63
# File 'lib/ferrum/network/request.rb', line 61

def xhr?
  type?("xhr")
end