class Miteru::Attachement

Attributes

url[R]

Public Class Methods

new(url) click to toggle source
# File lib/miteru/attachement.rb, line 9
def initialize(url)
  @url = url
end

Public Instance Methods

to_a() click to toggle source
# File lib/miteru/attachement.rb, line 13
def to_a
  [
    {
      text: defanged_url,
      fallback: "VT & urlscan.io links",
      actions: actions
    }
  ]
end

Private Instance Methods

actions() click to toggle source
# File lib/miteru/attachement.rb, line 25
def actions
  [vt_link, urlscan_link].compact
end
defanged_url() click to toggle source
# File lib/miteru/attachement.rb, line 49
def defanged_url
  @defanged_url ||= url.to_s.gsub /\./, "[.]"
end
domain() click to toggle source
# File lib/miteru/attachement.rb, line 53
def domain
  @domain ||=
    [].tap do |out|
      out << URI(url).hostname
    rescue URI::Error => _e
      out << nil
    end.first
end