<commit_before>module TellStickR

  class Device

    def self.discover
      
    end

  end

end<commit_msg>Device class<commit_after>module TellStickR

  class Device

    attr_reader :id, :name, :protocol, :model

    def initialize(id, name, protocol, model)
      @id = id
      @name = name
      @protocol = protocol
      @model = model
    end

    def learn
      result = TellStickR::Core.tdLearn(@id)
      return true if result == TellStickR::Core::TELLSTICK_SUCCESS
      raise TellStickR::Error.new(result)
    end

    def on
      result = TellStickR::Core.tdTurnOn(@id)
      return true if result == TellStickR::Core::TELLSTICK_SUCCESS
      raise TellStickR::Error.new(result)
    end

    def off
      result = TellStickR::Core.tdTurnOff(@id)
      return true if result == TellStickR::Core::TELLSTICK_SUCCESS
      raise TellStickR::Error.new(result)
    end

    def bell
      result = TellStickR::Core.tdBell(@id)
      return true if result == TellStickR::Core::TELLSTICK_SUCCESS
      raise TellStickR::Error.new(result)
    end

    def self.discover
      nr_of_devices = TellStickR::Core.tdGetNumberOfDevices
      i = 0
      devices = []
      while(i < nr_of_devices) do
        id = TellStickR::Core.tdGetDeviceId(i)
        name = TellStickR::Core.tdGetName(i)
        protocol = TellStickR::Core.tdGetProtocol(i)
        model = TellStickR::Core.tdGetModel(i)
        devices << Device.new(id, name, protocol, model)
        i += 1
      end
      devices
    end

  end

end
{'fraction_non_alphanumeric': 0.09583608724388631, 'fraction_numerical': 0.0013218770654329147, 'mean_word_length': 2.6220095693779903, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6240455', 'n_tokens_mistral': 513, 'n_tokens_neox': 495, 'n_words': 110}