Class: Standupguy::Item::TicketUrl

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

Constant Summary collapse

CLASSIC_TICKET =
%r{https?:\/\/(.*?)\.zendesk.com\/[a-z].*?\/(.*)}
LOTUS_TICKET =
%r{https?:\/\/(.*?)\.zendesk.com\/agent\/#?\/?tickets\/(\d+)\/?.*?}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ TicketUrl

Returns a new instance of TicketUrl.



219
220
221
222
223
224
225
# File 'lib/Standupguy.rb', line 219

def initialize(url)
  [LOTUS_TICKET, CLASSIC_TICKET].each do |pattern|
    subdomain, id = url.downcase.scan(pattern).flatten
    super(url, subdomain, id)
    return if self.valid?
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



215
216
217
# File 'lib/Standupguy.rb', line 215

def id
  @id
end

#subdomainObject

Returns the value of attribute subdomain

Returns:

  • (Object)

    the current value of subdomain



215
216
217
# File 'lib/Standupguy.rb', line 215

def subdomain
  @subdomain
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



215
216
217
# File 'lib/Standupguy.rb', line 215

def url
  @url
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


227
228
229
# File 'lib/Standupguy.rb', line 227

def valid?
  !(id.nil? && subdomain.nil?)
end