Class: Vertx::Cookie

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb

Overview

Represents an HTTP Cookie.

All cookies must have a name and a value and can optionally have other fields set such as path, domain, etc.

Direct Known Subclasses

VertxWeb::Cookie

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

19
20
21
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 19

def @@j_api_type.accept?(obj)
  obj.class == Cookie
end
Create a new cookie

Parameters:

  • name (String) (defaults to: nil)
    the name of the cookie
  • value (String) (defaults to: nil)
    the cookie value

Returns:

Raises:

  • (ArgumentError)

38
39
40
41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 38

def self.cookie(name=nil,value=nil)
  if name.class == String && value.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::Cookie.java_method(:cookie, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value),::Vertx::Cookie)
  end
  raise ArgumentError, "Invalid arguments when calling cookie(#{name},#{value})"
end

+ (Object) j_api_type


28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 28

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 31

def self.j_class
  Java::IoVertxCoreHttp::Cookie.java_class
end

+ (Object) unwrap(obj)


25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 25

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 22

def @@j_api_type.wrap(obj)
  Cookie.new(obj)
end

Instance Method Details

- (String) encode

Encode the cookie to a string. This is what is used in the Set-Cookie header

Returns:

  • (String)
    the encoded cookie

Raises:

  • (ArgumentError)

143
144
145
146
147
148
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 143

def encode
  if !block_given?
    return @j_del.java_method(:encode, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling encode()"
end

- (String) get_domain

Returns the domain for the cookie

Returns:

  • (String)
    the domain for the cookie

Raises:

  • (ArgumentError)

79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 79

def get_domain
  if !block_given?
    return @j_del.java_method(:getDomain, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_domain()"
end

- (String) get_name

Returns the name of this cookie

Returns:

  • (String)
    the name of this cookie

Raises:

  • (ArgumentError)

45
46
47
48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 45

def get_name
  if !block_given?
    return @j_del.java_method(:getName, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_name()"
end

- (String) get_path

Returns the path for this cookie

Returns:

  • (String)
    the path for this cookie

Raises:

  • (ArgumentError)

96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 96

def get_path
  if !block_given?
    return @j_del.java_method(:getPath, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_path()"
end

- (String) get_value

Returns the value of this cookie

Returns:

  • (String)
    the value of this cookie

Raises:

  • (ArgumentError)

52
53
54
55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 52

def get_value
  if !block_given?
    return @j_del.java_method(:getValue, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_value()"
end

- (self) set_domain(domain = nil)

Sets the domain of this cookie

Parameters:

  • domain (String) (defaults to: nil)
    The domain to use

Returns:

  • (self)

Raises:

  • (ArgumentError)

71
72
73
74
75
76
77
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 71

def set_domain(domain=nil)
  if domain.class == String && !block_given?
    @j_del.java_method(:setDomain, [Java::java.lang.String.java_class]).call(domain)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_domain(#{domain})"
end

- (self) set_http_only(httpOnly = nil)

Determines if this cookie is HTTP only. If set to true, this cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For for information, please look here.

Parameters:

  • httpOnly (true, false) (defaults to: nil)
    True if the cookie is HTTP only, otherwise false.

Returns:

  • (self)

Raises:

  • (ArgumentError)

134
135
136
137
138
139
140
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 134

def set_http_only(httpOnly=nil)
  if (httpOnly.class == TrueClass || httpOnly.class == FalseClass) && !block_given?
    @j_del.java_method(:setHttpOnly, [Java::boolean.java_class]).call(httpOnly)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_http_only(#{httpOnly})"
end

- (self) set_max_age(maxAge = nil)

Sets the maximum age of this cookie in seconds. If an age of 0 is specified, this cookie will be automatically removed by browser because it will expire immediately. If MIN_VALUE is specified, this cookie will be removed when the browser is closed. If you don't set this the cookie will be a session cookie and be removed when the browser is closed.

Parameters:

  • maxAge (Fixnum) (defaults to: nil)
    The maximum age of this cookie in seconds

Returns:

  • (self)

Raises:

  • (ArgumentError)

110
111
112
113
114
115
116
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 110

def set_max_age(maxAge=nil)
  if maxAge.class == Fixnum && !block_given?
    @j_del.java_method(:setMaxAge, [Java::long.java_class]).call(maxAge)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_max_age(#{maxAge})"
end

- (self) set_path(path = nil)

Sets the path of this cookie.

Parameters:

  • path (String) (defaults to: nil)
    The path to use for this cookie

Returns:

  • (self)

Raises:

  • (ArgumentError)

88
89
90
91
92
93
94
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 88

def set_path(path=nil)
  if path.class == String && !block_given?
    @j_del.java_method(:setPath, [Java::java.lang.String.java_class]).call(path)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_path(#{path})"
end

- (self) set_secure(secure = nil)

Sets the security getStatus of this cookie

Parameters:

  • secure (true, false) (defaults to: nil)
    True if this cookie is to be secure, otherwise false

Returns:

  • (self)

Raises:

  • (ArgumentError)

120
121
122
123
124
125
126
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 120

def set_secure(secure=nil)
  if (secure.class == TrueClass || secure.class == FalseClass) && !block_given?
    @j_del.java_method(:setSecure, [Java::boolean.java_class]).call(secure)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_secure(#{secure})"
end

- (self) set_value(value = nil)

Sets the value of this cookie

Parameters:

  • value (String) (defaults to: nil)
    The value to set

Returns:

  • (self)

Raises:

  • (ArgumentError)

61
62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/cookie.rb', line 61

def set_value(value=nil)
  if value.class == String && !block_given?
    @j_del.java_method(:setValue, [Java::java.lang.String.java_class]).call(value)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_value(#{value})"
end