Class: Description

Inherits:
Data
  • Object
show all
Defined in:
lib/inat-channel/data_types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



145
146
147
# File 'lib/inat-channel/data_types.rb', line 145

def value
  @value
end

Instance Method Details

#htmlObject



152
153
154
155
156
157
158
159
160
# File 'lib/inat-channel/data_types.rb', line 152

def html
  sanitized = Sanitize.fragment value, IC::SANITIZE_HTML_CONFIG
  if sanitized.length > IC::CONFIG.dig(:tg_bot, :desc_limit)
    # В отличие от простого текста, обрезка HTML требует куда более изощренной логики, что неоправданно
    text
  else
    sanitized
  end
end

#iconObject



146
147
148
# File 'lib/inat-channel/data_types.rb', line 146

def icon
  IC::ICONS[:description]
end

#textObject



149
150
151
# File 'lib/inat-channel/data_types.rb', line 149

def text
  Sanitize.fragment(value, IC::SANITIZE_TEXT_CONFIG).limit(IC::CONFIG.dig(:tg_bot, :desc_limit))
end