class Boom::Item
Attributes
name[RW]
Public: the String name of the Item
value[RW]
Public: the String value of the Item
Public Class Methods
new(name,value)
click to toggle source
Public Instance Methods
short_name()
click to toggle source
Public: the shortened String name of the Item
. Truncates with ellipses if larger.
Examples
item = Item.new("github's home page","https://github.com") item.short_name # => 'github's home p…' item = Item.new("github","https://github.com") item.short_name # => 'github'
Returns the shortened name.
# File lib/boom/item.rb, line 44 def short_name name.length > 15 ? "#{name[0..14]}…" : name[0..14] end
spacer()
click to toggle source
Public: the amount of consistent spaces to pad based on Item#short_name
.
Returns a String of spaces.
# File lib/boom/item.rb, line 51 def spacer name.length > 15 ? '' : ' '*(15-name.length+1) end
to_hash()
click to toggle source
Public: creates a Hash for this Item
.
Returns a Hash of its data.
# File lib/boom/item.rb, line 66 def to_hash { @name => @value } end
url()
click to toggle source
Public: only return url part of value - if no url has been detected it'll return the value.
Returns a String which preferably is a URL.
# File lib/boom/item.rb, line 59 def url @url ||= value.split(/\s+/).detect { |v| v =~ %r{\A[a-z0-9]+:\S+}i } || value end