require "maruku"

class Post
  attr_reader :card
  def initialize(card)
    @card = card
  end

  def title
    card.name
  end

  def body
    text = card.desc
    md_to_html(text)
  end

  def sponsored?
    card.labels.any? { |label| label.name == "Sponsored" }
  end

  private

  def md_to_html(text)
    Maruku.new(text).to_html
  end
end

require "maruku"

class Post
  attr_reader :card
  def initialize(card)
    @card = card
  end

  def title
    card.name
  end

  def body
    text = card.desc
    md_to_html(text)
  end
  
  def attachment
    attachment = card.attachments.first
    if (attachment.nil?)
      return nil
    end
    card.attachments.first.attributes[:url]  # Any attachments are hosted by trello
  end

  def sponsored?
    card.labels.any? { |label| label.name == "Sponsored" }
  end

  private

  def md_to_html(text)
    Maruku.new(text).to_html
  end
end

Add method to get attachment from card
Add method to get attachment from card

This method will get the url attached to a card. If there's no
attachment then it will return nil and the html generator will handle
that situation.
