Sha256: 0c15e99e88e6f8639fecb20e079b1ef5dc8c1223e438469e85ef7216df1b45fe

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 Bytes

Contents

require 'nokogiri'
require 'open-uri'

module AZEROTHFaker
  class Character
    noko = Nokogiri::HTML(open("http://wowwiki.wikia.com/wiki/Major_characters"))
    @names = noko.search('#mw-content-text > a').map {|name| name.inner_text}

    def self.random_name
      @names.sample
    end

    def self.first_name
      @name = @names.sample.split
      return name[0]
    end

    def self.last_name
      name = @names.sample.split
      while name.length < 1
        name = @names.sample
      end
      return name[-1]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
azeroth_faker-0.1.0 lib/azeroth_faker/character.rb