Class: Twitter::Arguments

Inherits:
Array
  • Object
show all
Defined in:
lib/twitter/arguments.rb

Overview

An Array subclass that extracts options from arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Twitter::Arguments

Initializes a new Arguments object

Examples:

args = Twitter::Arguments.new([:user1, :user2, {trim_user: true}])
args # => [:user1, :user2]
args.options # => {trim_user: true}

Parameters:

  • args (Array)

    An array of arguments, optionally ending with a Hash



22
23
24
25
# File 'lib/twitter/arguments.rb', line 22

def initialize(args)
  @options = args.last.is_a?(Hash) ? args.pop : {} # : Hash[Symbol, untyped]
  super(args.flatten)
end

Instance Attribute Details

#optionsHash (readonly)

The options hash extracted from the arguments

Examples:

args = Twitter::Arguments.new([:user1, :user2, {trim_user: true}])
args.options # => {trim_user: true}

Returns:

  • (Hash)


11
12
13
# File 'lib/twitter/arguments.rb', line 11

def options
  @options
end