Class: Guillotine::Service::Options

Inherits:
Struct
  • Object
show all
Defined in:
lib/guillotine/service.rb

Overview

length - Optional Integer maximum length of the short code desired. charset - Optional Array of String characters which will be present in

short code.  eg. ['a', 'b', 'c', 'd', 'e', 'f']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#charsetObject

Returns the value of attribute charset

Returns:

  • (Object)

    the current value of charset



9
10
11
# File 'lib/guillotine/service.rb', line 9

def charset
  @charset
end

#default_urlObject

Returns the value of attribute default_url

Returns:

  • (Object)

    the current value of default_url



9
10
11
# File 'lib/guillotine/service.rb', line 9

def default_url
  @default_url
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



9
10
11
# File 'lib/guillotine/service.rb', line 9

def length
  @length
end

#required_hostObject

Returns the value of attribute required_host

Returns:

  • (Object)

    the current value of required_host



9
10
11
# File 'lib/guillotine/service.rb', line 9

def required_host
  @required_host
end

#strip_anchorObject

Returns the value of attribute strip_anchor

Returns:

  • (Object)

    the current value of strip_anchor



9
10
11
# File 'lib/guillotine/service.rb', line 9

def strip_anchor
  @strip_anchor
end

#strip_queryObject

Returns the value of attribute strip_query

Returns:

  • (Object)

    the current value of strip_query



9
10
11
# File 'lib/guillotine/service.rb', line 9

def strip_query
  @strip_query
end

Class Method Details

.from(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/guillotine/service.rb', line 11

def self.from(value)
  case value
  when nil, "" then new
  when String, Regexp then new(value)
  when Hash then
    opt = new
    value.each do |key, value|
      opt[key] = value
    end
    opt
  when Options then value
  else
    raise ArgumentError, "Unable to convert to Options: #{value.inspect}"
  end
end

Instance Method Details

#host_checkerObject



39
40
41
# File 'lib/guillotine/service.rb', line 39

def host_checker
  @host_checker ||= HostChecker.matching(required_host)
end

#strip_anchor?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/guillotine/service.rb', line 31

def strip_anchor?
  strip_anchor != false
end

#strip_query?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/guillotine/service.rb', line 27

def strip_query?
  strip_query != false
end

#with_charset?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/guillotine/service.rb', line 35

def with_charset?
  !(length.nil? || charset.nil?)
end