class DingTalk::Command::FeedCard

Public Class Methods

new(argv) click to toggle source
Calls superclass method DingTalk::Command::new
# File lib/DingTalk/command/feed_card.rb, line 23
def initialize(argv)
  links_str = argv.shift_argument
  @links = []
  if links_str then
    begin
      JSON.parser(links_str).each do | link |
        @links << DingTalk::Message::FeedCardLink.new(link.title, link.pic, link.link) if link.title && link.pic && link.link
      end
    rescue
    ensure
    end
  end
  super
end
options() click to toggle source
Calls superclass method DingTalk::Command::options
# File lib/DingTalk/command/feed_card.rb, line 18
def self.options
  [
  ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/DingTalk/command/feed_card.rb, line 43
def run
  res = DingTalk::HttpHelper.send_feed_card(@links, @token, @secret)
  puts res.bold.green
end
validate!() click to toggle source
Calls superclass method
# File lib/DingTalk/command/feed_card.rb, line 38
def validate!
  super
  help! 'A message button is required.' unless @links.size < 1
end